Index: tests/corelib/uri_normalize_test.dart |
diff --git a/tests/corelib/uri_normalize_test.dart b/tests/corelib/uri_normalize_test.dart |
index 91bbe10f1c1bc8b047012531a1ec4288d0240103..5c2f8140c0800bbc8459aa3f8843c8e5edd3d2f6 100644 |
--- a/tests/corelib/uri_normalize_test.dart |
+++ b/tests/corelib/uri_normalize_test.dart |
@@ -5,10 +5,12 @@ |
import "package:expect/expect.dart"; |
testNormalizePath() { |
- test(String expected, String path) { |
- var uri = new Uri(path: path); |
- Expect.equals(expected, uri.path); |
+ test(String expected, String path, {String scheme, String host}) { |
+ var uri = new Uri(scheme: scheme, host: host, path: path); |
Expect.equals(expected, uri.toString()); |
+ if (scheme == null && host == null) { |
+ Expect.equals(expected, uri.path); |
+ } |
} |
var unreserved = "-._~0123456789" |
@@ -32,9 +34,42 @@ testNormalizePath() { |
x.write(i.toRadixString(16)); |
} |
} |
- print(x.toString().toUpperCase()); |
Expect.equals(x.toString().toUpperCase(), |
new Uri(path: x.toString()).toString().toUpperCase()); |
+ |
+ // Normalized paths. |
+ |
+ // Full absolute path normalization for absolute paths. |
+ test("/a/b/c/", "/../a/./b/z/../c/d/.."); |
+ test("/a/b/c/", "/./a/b/c/"); |
+ test("/a/b/c/", "/./../a/b/c/"); |
+ test("/a/b/c/", "/./../a/b/c/."); |
+ test("/a/b/c/", "/./../a/b/c/z/./.."); |
+ test("/", "/a/.."); |
+ // Full absolute path normalization for URIs with scheme. |
+ test("s:a/b/c/", "../a/./b/z/../c/d/..", scheme: "s"); |
+ test("s:a/b/c/", "./a/b/c/", scheme: "s"); |
+ test("s:a/b/c/", "./../a/b/c/", scheme: "s"); |
+ test("s:a/b/c/", "./../a/b/c/.", scheme: "s"); |
+ test("s:a/b/c/", "./../a/b/c/z/./..", scheme: "s"); |
+ test("s:/", "/a/..", scheme: "s"); |
+ test("s:/", "a/..", scheme: "s"); |
+ // Full absolute path normalization for URIs with authority. |
+ test("//h/a/b/c/", "../a/./b/z/../c/d/..", host: "h"); |
+ test("//h/a/b/c/", "./a/b/c/", host: "h"); |
+ test("//h/a/b/c/", "./../a/b/c/", host: "h"); |
+ test("//h/a/b/c/", "./../a/b/c/.", host: "h"); |
+ test("//h/a/b/c/", "./../a/b/c/z/./..", host: "h"); |
+ test("//h/", "/a/..", host: "h"); |
+ test("//h/", "a/..", host: "h"); |
+ // Partial relative normalization (allowing leading .. or ./ for current dir). |
+ test("../a/b/c/", "../a/./b/z/../c/d/.."); |
+ test("a/b/c/", "./a/b/c/"); |
+ test("../a/b/c/", "./../a/b/c/"); |
+ test("../a/b/c/", "./../a/b/c/."); |
+ test("../a/b/c/", "./../a/b/c/z/./.."); |
+ test("/", "/a/.."); |
+ test("./", "a/.."); |
} |
main() { |