1 description("Canonicalization of standard URLs"); 2 3 cases = [ 4 ["http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#"], 5 ["http://[www.google.com]/", "http://[www.google.com]/"], 6 // Disabled because whitespace gets treated different in this API. 7 // ["ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#"], 8 ["http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo"], 9 // Disabled because this gets treated as a relative URL. 10 // ["www.google.com", ":www.google.com/"], 11 ["http://192.0x00A80001", "http://192.168.0.1/"], 12 ["http://www/foo%2Ehtml", "http://www/foo.html"], 13 ["http://user:pass@/", "http://user:pass@/"], 14 ["http://%25DOMAIN:foobar@foodomain.com/", "http://%25DOMAIN:foobar@foodomain.com/"], 15 // Backslashes should get converted to forward slashes. 16 ["http:\\\\\\\\www.google.com\\\\foo", "http://www.google.com/foo"], 17 // Busted refs shouldn't make the whole thing fail. 18 ["http://www.google.com/asdf#\\ud800", "http://www.google.com/asdf#\\uFFFD"], 19 // Basic port tests. 20 ["http://foo:80/", "http://foo/"], 21 ["http://foo:81/", "http://foo:81/"], 22 ["httpa://foo:80/", "httpa://foo:80/"], 23 ["http://foo:-80/", "http://foo:-80/"], 24 ["https://foo:443/", "https://foo/"], 25 ["https://foo:80/", "https://foo:80/"], 26 ["ftp://foo:21/", "ftp://foo/"], 27 ["ftp://foo:80/", "ftp://foo:80/"], 28 ["gopher://foo:70/", "gopher://foo/"], 29 ["gopher://foo:443/", "gopher://foo:443/"], 30 ["ws://foo:80/", "ws://foo/"], 31 ["ws://foo:81/", "ws://foo:81/"], 32 ["ws://foo:443/", "ws://foo:443/"], 33 ["ws://foo:815/", "ws://foo:815/"], 34 ["wss://foo:80/", "wss://foo:80/"], 35 ["wss://foo:81/", "wss://foo:81/"], 36 ["wss://foo:443/", "wss://foo/"], 37 ["wss://foo:815/", "wss://foo:815/"], 38 ]; 39 40 for (var i = 0; i < cases.length; ++i) { 41 test_vector = cases[i][0]; 42 expected_result = cases[i][1]; 43 shouldBe("canonicalize('" + test_vector + "')", 44 "'" + expected_result + "'"); 45 } 46 47 var successfullyParsed = true; 48