OLD | NEW |
1 description("Test URL segmentation"); | 1 description("Test URL segmentation"); |
2 | 2 |
3 cases = [ | 3 cases = [ |
4 // [URL, [SCHEME, HOST, PORT, PATH, QUERY, REF]] | 4 // [URL, [SCHEME, HOST, PORT, PATH, QUERY, REF]] |
5 ["http://user:pass@foo:21/bar;par?b#c", ["http:","foo","21","/bar;par","?b"
,"#c"]], | 5 ["http://user:pass@foo:21/bar;par?b#c", ["http:","foo","21","/bar;par","?b"
,"#c"]], |
6 ["http:foo.com", ["http:","foo.com","","/","",""]], | 6 ["http:foo.com", ["http:","foo.com","","/","",""]], |
7 ["\\t :foo.com \\n", [":","","","","",""]], | 7 ["\\t :foo.com \\n", [":","","","","",""]], |
8 [" foo.com ", [":","","","","",""]], | 8 [" foo.com ", [":","","","","",""]], |
9 ["a:\\t foo.com", ["a:","",""," foo.com","",""]], | 9 ["a:\\t foo.com", ["a:","",""," foo.com","",""]], |
10 ["http://f:21/ b ? d # e ", ["http:","f","21","/%20b%20","?%20d
%20","# e"]], | 10 ["http://f:21/ b ? d # e ", ["http:","f","21","/%20b%20","?%20d
%20","# e"]], |
(...skipping 16 matching lines...) Expand all Loading... |
27 [":/", [":","","","","",""]], | 27 [":/", [":","","","","",""]], |
28 [":\\\\", [":","","","","",""]], | 28 [":\\\\", [":","","","","",""]], |
29 [":#", [":","","","","",""]], | 29 [":#", [":","","","","",""]], |
30 ["#", ["data:","","","text/plain,baseURL"
,"",""]], | 30 ["#", ["data:","","","text/plain,baseURL"
,"",""]], |
31 ["#/", ["data:","","","text/plain,baseURL"
,"","#/"]], | 31 ["#/", ["data:","","","text/plain,baseURL"
,"","#/"]], |
32 ["#\\\\", ["data:","","","text/plain,baseURL"
,"","#\\\\"]], | 32 ["#\\\\", ["data:","","","text/plain,baseURL"
,"","#\\\\"]], |
33 ["#;?", ["data:","","","text/plain,baseURL"
,"","#;?"]], | 33 ["#;?", ["data:","","","text/plain,baseURL"
,"","#;?"]], |
34 ["?", [":","","","","",""]], | 34 ["?", [":","","","","",""]], |
35 ["/", [":","","","","",""]], | 35 ["/", [":","","","","",""]], |
36 [":23", [":","","","","",""]], | 36 [":23", [":","","","","",""]], |
37 ["/:23", ["data:","","","/:23","",""]], | 37 ["/:23", [":","","","","",""]], |
38 ["//", [":","","","","",""]], | 38 ["//", [":","","","","",""]], |
39 ["::", [":","","","","",""]], | 39 ["::", [":","","","","",""]], |
40 ["::23", [":","","","","",""]], | 40 ["::23", [":","","","","",""]], |
41 ["foo://", ["foo:","","","//","",""]], | 41 ["foo://", ["foo:","","","//","",""]], |
42 ["http://a:b@c:29/d", ["http:","c","29","/d","",""]], | 42 ["http://a:b@c:29/d", ["http:","c","29","/d","",""]], |
43 ["http::@c:29", ["http:","c","29","/","",""]], | 43 ["http::@c:29", ["http:","c","29","/","",""]], |
44 ["http://&a:foo(b]c@d:2/", ["http:","d","2","/","",""]], | 44 ["http://&a:foo(b]c@d:2/", ["http:","d","2","/","",""]], |
45 ["http://::@c@d:2", ["http:","d","2","/","",""]], | 45 ["http://::@c@d:2", ["http:","d","2","/","",""]], |
46 ["http://foo.com:b@d/", ["http:","d","","/","",""]], | 46 ["http://foo.com:b@d/", ["http:","d","","/","",""]], |
47 ["http://foo.com/\\\\@", ["http:","foo.com","","//@","",""]]
, | 47 ["http://foo.com/\\\\@", ["http:","foo.com","","//@","",""]]
, |
48 ["http:\\\\\\\\foo.com\\\\", ["http:","foo.com","","/","",""]], | 48 ["http:\\\\\\\\foo.com\\\\", ["http:","foo.com","","/","",""]], |
49 ["http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\", ["http:","a","","/b:c/d@foo.com/","
",""]], | 49 ["http:\\\\\\\\a\\\\b:c\\\\d@foo.com\\\\", ["http:","a","","/b:c/d@foo.com/","
",""]], |
50 ["foo:/", ["foo:","","","/","",""]], | 50 ["foo:/", ["foo:","","","/","",""]], |
51 ["foo:/bar.com/", ["foo:","","","/bar.com/","",""]], | 51 ["foo:/bar.com/", ["foo:","","","/bar.com/","",""]], |
52 ["foo://///////", ["foo:","","","/////////","",""]], | 52 ["foo://///////", ["foo:","","","/////////","",""]], |
53 ["foo://///////bar.com/", ["foo:","","","/////////bar.com/","
",""]], | 53 ["foo://///////bar.com/", ["foo:","","","/////////bar.com/","
",""]], |
54 ["foo:////://///", ["foo:","","","////://///","",""]], | 54 ["foo:////://///", ["foo:","","","////://///","",""]], |
55 ["c:/foo", ["c:","","","/foo","",""]], | 55 ["c:/foo", ["c:","","","/foo","",""]], |
56 ["//foo/bar", [":","","","","",""]], | 56 ["//foo/bar", [":","","","","",""]], |
57 ["http://foo/path;a??e#f#g", ["http:","foo","","/path;a","??e","
#f#g"]], | 57 ["http://foo/path;a??e#f#g", ["http:","foo","","/path;a","??e","
#f#g"]], |
58 ["http://foo/abcd?efgh?ijkl", ["http:","foo","","/abcd","?efgh?ij
kl",""]], | 58 ["http://foo/abcd?efgh?ijkl", ["http:","foo","","/abcd","?efgh?ij
kl",""]], |
59 ["http://foo/abcd#foo?bar", ["http:","foo","","/abcd","","#foo?
bar"]], | 59 ["http://foo/abcd#foo?bar", ["http:","foo","","/abcd","","#foo?
bar"]], |
60 ["[61:24:74]:98", ["data:","","","text/[61:24:74]:98"
,"",""]], | 60 ["[61:24:74]:98", [":","","","","",""]], |
61 ["http://[61:27]:98", [":","","0","","",""]], | 61 ["http://[61:27]:98", [":","","0","","",""]], |
62 ["http:[61:27]/:foo", [":","","","","",""]], | 62 ["http:[61:27]/:foo", [":","","","","",""]], |
63 ["http://[1::2]:3:4", [":","","","","",""]], | 63 ["http://[1::2]:3:4", [":","","","","",""]], |
64 ["http://2001::1", [":","","","","",""]], | 64 ["http://2001::1", [":","","","","",""]], |
65 ["http://[2001::1", [":","","","","",""]], | 65 ["http://[2001::1", [":","","","","",""]], |
66 ["http://2001::1]", [":","","","","",""]], | 66 ["http://2001::1]", [":","","","","",""]], |
67 ["http://2001::1]:80", [":","","","","",""]], | 67 ["http://2001::1]:80", [":","","","","",""]], |
68 ["http://[2001::1]", ["http:","[2001::1]","","/","",""]]
, | 68 ["http://[2001::1]", ["http:","[2001::1]","","/","",""]]
, |
69 ["http://[2001::1]:80", ["http:","[2001::1]","","/","",""]]
, | 69 ["http://[2001::1]:80", ["http:","[2001::1]","","/","",""]]
, |
70 ["http://[[::]]", [":","","","","",""]], | 70 ["http://[[::]]", [":","","","","",""]], |
71 ]; | 71 ]; |
72 | 72 |
73 var originalBaseURL = canonicalize("."); | 73 var originalBaseURL = canonicalize("."); |
74 setBaseURL("data:text/plain,baseURL"); | 74 setBaseURL("data:text/plain,baseURL"); |
75 | 75 |
76 for (var i = 0; i < cases.length; ++i) { | 76 for (var i = 0; i < cases.length; ++i) { |
77 shouldBe("segments('" + cases[i][0] + "')", | 77 shouldBe("segments('" + cases[i][0] + "')", |
78 "'" + JSON.stringify(cases[i][1]) + "'"); | 78 "'" + JSON.stringify(cases[i][1]) + "'"); |
79 } | 79 } |
80 | 80 |
81 setBaseURL(originalBaseURL); | 81 setBaseURL(originalBaseURL); |
OLD | NEW |