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

Unified Diff: pkg/front_end/lib/src/base/resolve_relative_uri.dart

Issue 2668553002: Move resolveRelativeUri into front_end. (Closed)
Patch Set: Created 3 years, 11 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: pkg/front_end/lib/src/base/resolve_relative_uri.dart
diff --git a/pkg/front_end/lib/src/base/resolve_relative_uri.dart b/pkg/front_end/lib/src/base/resolve_relative_uri.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cafcbf2ef969613c5bc6932396dd6f11459cb92a
--- /dev/null
+++ b/pkg/front_end/lib/src/base/resolve_relative_uri.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2017, 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.
+
+/**
+ * Resolve the [containedUri] against [baseUri] using Dart rules.
+ *
+ * This function behaves similarly to [Uri.resolveUri], except that it properly
+ * handles situations like the following:
+ *
+ * resolveRelativeUri(dart:core, bool.dart) -> dart:core/bool.dart
+ * resolveRelativeUri(package:a/b.dart, ../c.dart) -> package:a/c.dart
+ */
+Uri resolveRelativeUri(Uri baseUri, Uri containedUri) {
+ if (containedUri.isAbsolute) {
+ return containedUri;
+ }
+ String scheme = baseUri.scheme;
+ // dart:core => dart:core/core.dart
+ if (scheme == 'dart') {
+ String part = baseUri.path;
+ if (part.indexOf('/') < 0) {
+ baseUri = Uri.parse('$scheme:$part/$part.dart');
+ }
+ }
+ return baseUri.resolveUri(containedUri);
+}
« no previous file with comments | « pkg/analyzer/lib/src/generated/utilities_dart.dart ('k') | pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698