Chromium Code Reviews

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 16019002: Merge the dart:uri library into dart:core and update the Uri class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing files Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: sdk/lib/_internal/pub/lib/src/utils.dart
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 0311c9ded582b4bca6482da5bf0fc36472e0766e..bc90fdab4f9aae998b63422365fd5d2631850598 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -11,7 +11,6 @@ import 'dart:io';
import 'dart:isolate';
import 'dart:json' as json;
import 'dart:mirrors';
-import 'dart:uri';
import 'package:pathos/path.dart' as path;
@@ -321,8 +320,9 @@ Map<String, String> queryToMap(String queryList) {
String mapToQuery(Map<String, String> map) {
var pairs = <List<String>>[];
map.forEach((key, value) {
- key = encodeUriComponent(key);
- value = (value == null || value.isEmpty) ? null : encodeUriComponent(value);
+ key = Uri.encodeQueryComponent(key);
+ value = (value == null || value.isEmpty)
+ ? null : Uri.encodeQueryComponent(value);
pairs.add([key, value]);
});
return pairs.map((pair) {
@@ -339,13 +339,6 @@ bool urisEqual(Uri uri1, Uri uri2) =>
/// Return [uri] with redundant port information removed.
Uri canonicalizeUri(Uri uri) {
- if (uri == null) return null;
-
- var sansPort = new Uri.fromComponents(
- scheme: uri.scheme, userInfo: uri.userInfo, domain: uri.domain,
- path: uri.path, query: uri.query, fragment: uri.fragment);
- if (uri.scheme == 'http' && uri.port == 80) return sansPort;
- if (uri.scheme == 'https' && uri.port == 443) return sansPort;
return uri;
}
@@ -354,10 +347,10 @@ Uri canonicalizeUri(Uri uri) {
void mapAddAll(Map destination, Map source) =>
source.forEach((key, value) => destination[key] = value);
-/// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes
+/// Decodes a URL-encoded string. Unlike [Uri.decodeComponent], this includes
/// replacing `+` with ` `.
String urlDecode(String encoded) =>
- decodeUriComponent(encoded.replaceAll("+", " "));
+ Uri.decodeComponent(encoded.replaceAll("+", " "));
/// Takes a simple data structure (composed of [Map]s, [Iterable]s, scalar
/// objects, and [Future]s) and recursively resolves all the [Future]s contained

Powered by Google App Engine