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

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: 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
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) {
ngeoffray 2012/04/24 14:29:46 Why isn't that method in uri instead?
ahe 2012/04/24 14:55:34 I'm not sure if it belongs there.
+ 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();
+}

Powered by Google App Engine
This is Rietveld 408576698