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

Unified Diff: pkg/compiler/lib/src/util/uri_extras.dart

Issue 588183002: Emit warning on import of dart:mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Optimize and limit import chain processing Created 6 years, 1 month 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: pkg/compiler/lib/src/util/uri_extras.dart
diff --git a/pkg/compiler/lib/src/util/uri_extras.dart b/pkg/compiler/lib/src/util/uri_extras.dart
index 65a4ed2516112ac27787c9719d5cc45e73642d4c..aa8cdcf7f129271ecbf3c01f5a395248435cc56c 100644
--- a/pkg/compiler/lib/src/util/uri_extras.dart
+++ b/pkg/compiler/lib/src/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;

Powered by Google App Engine
This is Rietveld 408576698