Index: sdk/lib/_internal/compiler/implementation/util/uri_extras.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/util/uri_extras.dart b/sdk/lib/_internal/compiler/implementation/util/uri_extras.dart |
index 65a4ed2516112ac27787c9719d5cc45e73642d4c..aa8cdcf7f129271ecbf3c01f5a395248435cc56c 100644 |
--- a/sdk/lib/_internal/compiler/implementation/util/uri_extras.dart |
+++ b/sdk/lib/_internal/compiler/implementation/util/uri_extras.dart |
@@ -7,18 +7,20 @@ library uri_extras; |
import 'dart:math'; |
String relativize(Uri base, Uri uri, bool isWindows) { |
- if (!base.path.startsWith('/')) { |
- // Also throw an exception if [base] or base.path is null. |
- throw new ArgumentError('Expected absolute path: ${base.path}'); |
- } |
- if (!uri.path.startsWith('/')) { |
- // Also throw an exception if [uri] or uri.path is null. |
- throw new ArgumentError('Expected absolute path: ${uri.path}'); |
- } |
bool equalsNCS(String a, String b) { |
return a.toLowerCase() == b.toLowerCase(); |
} |
+ if (!equalsNCS(base.scheme, uri.scheme) || |
+ equalsNCS(base.scheme, 'dart') || |
+ equalsNCS(base.scheme, 'package')) { |
+ return uri.toString(); |
+ } |
+ |
+ if (!equalsNCS(base.scheme, 'file')) { |
+ isWindows = false; |
+ } |
+ |
String normalize(String path) { |
if (isWindows) { |
return path.toLowerCase(); |
@@ -27,9 +29,7 @@ String relativize(Uri base, Uri uri, bool isWindows) { |
} |
} |
- if (equalsNCS(base.scheme, 'file') && |
- equalsNCS(base.scheme, uri.scheme) && |
- base.userInfo == uri.userInfo && |
+ if (base.userInfo == uri.userInfo && |
equalsNCS(base.host, uri.host) && |
base.port == uri.port && |
uri.query == "" && uri.fragment == "") { |
@@ -37,6 +37,11 @@ String relativize(Uri base, Uri uri, bool isWindows) { |
return uri.path.substring(base.path.lastIndexOf('/') + 1); |
} |
+ if (!base.path.startsWith('/') || |
+ !uri.path.startsWith('/')) { |
+ return uri.toString(); |
+ } |
+ |
List<String> uriParts = uri.path.split('/'); |
List<String> baseParts = base.path.split('/'); |
int common = 0; |