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

Unified Diff: sdk/lib/core/uri.dart

Issue 1083253002: Add normalizePath to Uri class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 5 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
« no previous file with comments | « no previous file | sdk/lib/io/http.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/uri.dart
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart
index 14e2d80199e2c0fe08d82585c57e45ef619d50e5..bbc491c7343e9ce0ea889c0c7353b809b72f43f3 100644
--- a/sdk/lib/core/uri.dart
+++ b/sdk/lib/core/uri.dart
@@ -981,6 +981,25 @@ class Uri {
return _queryParameters;
}
+ /**
+ * Returns an URI where the path has been normalized.
+ *
+ * A normalized path does not contain `.` segments or non-leading `..`
+ * segments.
+ * Only a relative path may contain leading `..` segments,
+ * a path that starts with `/` will also drop any leading `..` segments.
+ *
+ * This uses the same normalization strategy as [resolveUri], as specified by
+ * RFC 3986.
+ *
+ * Does not change any part of the URI except the path.
+ */
+ Uri normalizePath() {
+ String path = _removeDotSegments(_path);
+ if (identical(path, _path)) return this;
+ return this.replace(path: path);
+ }
+
static int _makePort(int port, String scheme) {
// Perform scheme specific normalization.
if (port != null && port == _defaultPort(scheme)) return null;
@@ -988,7 +1007,7 @@ class Uri {
}
/**
- * Check and normalize a most name.
+ * Check and normalize a host name.
*
* If the host name starts and ends with '[' and ']', it is considered an
* IPv6 address. If [strictIPv6] is false, the address is also considered
« no previous file with comments | « no previous file | sdk/lib/io/http.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698