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

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

Issue 10207010: Make dart2js work on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years, 8 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 | « dart/lib/compiler/implementation/filenames.dart ('k') | dart/utils/compiler/build_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('uri_extras');
6
7 #import('dart:uri');
8
9 String relativize(Uri base, Uri uri) {
10 if (base.scheme == 'file' &&
11 base.scheme == uri.scheme &&
12 base.userInfo == uri.userInfo &&
13 base.domain == uri.domain &&
14 base.port == uri.port &&
15 uri.query == "" && uri.fragment == "") {
16 if (uri.path.startsWith(base.path)) {
17 return uri.path.substring(base.path.length);
18 }
19 List<String> uriParts = uri.path.split('/');
20 List<String> baseParts = base.path.split('/');
21 int common = 0;
22 int length = Math.min(uriParts.length, baseParts.length);
23 while (common < length && uriParts[common] == baseParts[common]) {
24 common++;
25 }
26 StringBuffer sb = new StringBuffer();
27 for (int i = common + 1; i < baseParts.length; i++) {
28 sb.add('../');
29 }
30 for (int i = common; i < uriParts.length - 1; i++) {
31 sb.add('${uriParts[i]}/');
32 }
33 sb.add('${uriParts.last()}');
34 return sb.toString();
35 }
36 return uri.toString();
37 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/filenames.dart ('k') | dart/utils/compiler/build_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698