Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: lib/compiler/implementation/util/uri_extras.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/tree/tree.dart ('k') | lib/crypto/crypto.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('uri_extras'); 5 #library('uri_extras');
6 6
7 #import('dart:math');
7 #import('dart:uri'); 8 #import('dart:uri');
8 9
9 String relativize(Uri base, Uri uri) { 10 String relativize(Uri base, Uri uri) {
10 if (base.scheme == 'file' && 11 if (base.scheme == 'file' &&
11 base.scheme == uri.scheme && 12 base.scheme == uri.scheme &&
12 base.userInfo == uri.userInfo && 13 base.userInfo == uri.userInfo &&
13 base.domain == uri.domain && 14 base.domain == uri.domain &&
14 base.port == uri.port && 15 base.port == uri.port &&
15 uri.query == "" && uri.fragment == "") { 16 uri.query == "" && uri.fragment == "") {
16 if (uri.path.startsWith(base.path)) { 17 if (uri.path.startsWith(base.path)) {
17 return uri.path.substring(base.path.length); 18 return uri.path.substring(base.path.length);
18 } 19 }
19 List<String> uriParts = uri.path.split('/'); 20 List<String> uriParts = uri.path.split('/');
20 List<String> baseParts = base.path.split('/'); 21 List<String> baseParts = base.path.split('/');
21 int common = 0; 22 int common = 0;
22 int length = Math.min(uriParts.length, baseParts.length); 23 int length = min(uriParts.length, baseParts.length);
23 while (common < length && uriParts[common] == baseParts[common]) { 24 while (common < length && uriParts[common] == baseParts[common]) {
24 common++; 25 common++;
25 } 26 }
26 StringBuffer sb = new StringBuffer(); 27 StringBuffer sb = new StringBuffer();
27 for (int i = common + 1; i < baseParts.length; i++) { 28 for (int i = common + 1; i < baseParts.length; i++) {
28 sb.add('../'); 29 sb.add('../');
29 } 30 }
30 for (int i = common; i < uriParts.length - 1; i++) { 31 for (int i = common; i < uriParts.length - 1; i++) {
31 sb.add('${uriParts[i]}/'); 32 sb.add('${uriParts[i]}/');
32 } 33 }
33 sb.add('${uriParts.last()}'); 34 sb.add('${uriParts.last()}');
34 return sb.toString(); 35 return sb.toString();
35 } 36 }
36 return uri.toString(); 37 return uri.toString();
37 } 38 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/tree/tree.dart ('k') | lib/crypto/crypto.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698