1description("Canonicalization of standard URLs"); 2 3cases = [ 4 ["http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#"], 5 ["http://www.google.com/foo?bar=baz# \u00bb", "http://www.google.com/foo?bar=baz# \u00bb"], 6 ["http://[www.google.com]/", "http://[www.google.com]/"], 7 ["http://www.google.com", "http://www.google.com/"], 8 // Disabled because whitespace gets treated different in this API. 9 // ["ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#"], 10 ["http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo"], 11 // Disabled because this gets treated as a relative URL. 12 // ["www.google.com", ":www.google.com/"], 13 ["http://192.0x00A80001", "http://192.168.0.1/"], 14 ["http://www/foo%2Ehtml", "http://www/foo.html"], 15 ["http://user:pass@/", "http://user:pass@/"], 16 ["http://%25DOMAIN:foobar@foodomain.com/", "http://%25DOMAIN:foobar@foodomain.com/"], 17 // Backslashes should get converted to forward slashes. 18 ["http:\\\\\\\\www.google.com\\\\foo", "http://www.google.com/foo"], 19 // Busted refs shouldn't make the whole thing fail. 20 ["http://www.google.com/asdf#\\ud800", "http://www.google.com/asdf#\\uFFFD"], 21 // Basic port tests. 22 ["http://foo:80/", "http://foo/"], 23 ["http://foo:81/", "http://foo:81/"], 24 ["httpa://foo:80/", "httpa://foo:80/"], 25 ["http://foo:-80/", "http://foo:-80/"], 26 ["https://foo:443/", "https://foo/"], 27 ["https://foo:80/", "https://foo:80/"], 28 ["ftp://foo:21/", "ftp://foo/"], 29 ["ftp://foo:80/", "ftp://foo:80/"], 30 ["gopher://foo:70/", "gopher://foo/"], 31 ["gopher://foo:443/", "gopher://foo:443/"], 32 ["ws://foo:80/", "ws://foo/"], 33 ["ws://foo:81/", "ws://foo:81/"], 34 ["ws://foo:443/", "ws://foo:443/"], 35 ["ws://foo:815/", "ws://foo:815/"], 36 ["wss://foo:80/", "wss://foo:80/"], 37 ["wss://foo:81/", "wss://foo:81/"], 38 ["wss://foo:443/", "wss://foo/"], 39 ["wss://foo:815/", "wss://foo:815/"], 40 ["http:/example.com/", "http://example.com/"], 41 ["ftp:/example.com/", "ftp://example.com/"], 42 ["https:/example.com/", "https://example.com/"], 43 ["madeupscheme:/example.com/", "madeupscheme:/example.com/"], 44 ["file:/example.com/", "file://localhost/example.com/"], 45 ["ftps:/example.com/", "ftps:/example.com/"], 46 ["gopher:/example.com/", "gopher://example.com/"], 47 ["ws:/example.com/", "ws://example.com/"], 48 ["wss:/example.com/", "wss://example.com/"], 49 ["data:/example.com/", "data:/example.com/"], 50 ["javascript:/example.com/", "javascript:/example.com/"], 51 ["mailto:/example.com/", "mailto:/example.com/"], 52 ["http:example.com/", "http://example.com/"], 53 ["ftp:example.com/", "ftp://example.com/"], 54 ["https:example.com/", "https://example.com/"], 55 ["madeupscheme:example.com/", "madeupscheme:example.com/"], 56 ["ftps:example.com/", "ftps:example.com/"], 57 ["gopher:example.com/", "gopher://example.com/"], 58 ["ws:example.com/", "ws://example.com/"], 59 ["wss:example.com/", "wss://example.com/"], 60 ["data:example.com/", "data:example.com/"], 61 ["javascript:example.com/", "javascript:example.com/"], 62 ["mailto:example.com/", "mailto:example.com/"], 63 // Escaping of non hierarchical URLs 64 ["javascript:alert(\\t 1 \\n\\r)", "javascript:alert( 1 )"], 65 ['javascript:alert(" \1 \u03B2 ")', 'javascript:alert(" %01 %CE%B2 ")'], 66]; 67 68for (var i = 0; i < cases.length; ++i) { 69 test_vector = cases[i][0]; 70 expected_result = cases[i][1]; 71 shouldBe("canonicalize('" + test_vector + "')", 72 "'" + expected_result + "'"); 73} 74 75var successfullyParsed = true; 76