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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/lib/compiler/implementation/filenames.dart ('k') | dart/utils/compiler/build_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/util/uri_extras.dart
diff --git a/dart/lib/compiler/implementation/util/uri_extras.dart b/dart/lib/compiler/implementation/util/uri_extras.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d5e9a8fdbdd2e7f79962fcc84ae99dd0f6a2e350
--- /dev/null
+++ b/dart/lib/compiler/implementation/util/uri_extras.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('uri_extras');
+
+#import('dart:uri');
+
+String relativize(Uri base, Uri uri) {
+ if (base.scheme == 'file' &&
+ base.scheme == uri.scheme &&
+ base.userInfo == uri.userInfo &&
+ base.domain == uri.domain &&
+ base.port == uri.port &&
+ uri.query == "" && uri.fragment == "") {
+ if (uri.path.startsWith(base.path)) {
+ return uri.path.substring(base.path.length);
+ }
+ List<String> uriParts = uri.path.split('/');
+ List<String> baseParts = base.path.split('/');
+ int common = 0;
+ int length = Math.min(uriParts.length, baseParts.length);
+ while (common < length && uriParts[common] == baseParts[common]) {
+ common++;
+ }
+ StringBuffer sb = new StringBuffer();
+ for (int i = common + 1; i < baseParts.length; i++) {
+ sb.add('../');
+ }
+ for (int i = common; i < uriParts.length - 1; i++) {
+ sb.add('${uriParts[i]}/');
+ }
+ sb.add('${uriParts.last()}');
+ return sb.toString();
+ }
+ return uri.toString();
+}
« 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