| OLD | NEW |
| 1 description("Test resolution of relative URLs."); | 1 description("Test resolution of relative URLs."); |
| 2 | 2 |
| 3 cases = [ | 3 cases = [ |
| 4 // Format: [baseURL, relativeURL, expectedURL], | 4 // Format: [baseURL, relativeURL, expectedURL], |
| 5 // Basic absolute input. | 5 // Basic absolute input. |
| 6 ["http://host/a", "http://another/", "http://another/"], | 6 ["http://host/a", "http://another/", "http://another/"], |
| 7 ["http://host/a", "http:////another/", "http://another/"], | 7 ["http://host/a", "http:////another/", "http://another/"], |
| 8 // Empty relative URLs should only remove the ref part of the URL, | 8 // Empty relative URLs should only remove the ref part of the URL, |
| 9 // leaving the rest unchanged. | 9 // leaving the rest unchanged. |
| 10 ["http://foo/bar", "", "http://foo/bar"], | 10 ["http://foo/bar", "", "http://foo/bar"], |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 ["http://host/a/", "././.", "http://host/a/"], | 40 ["http://host/a/", "././.", "http://host/a/"], |
| 41 ["http://host/a?query#ref", "../../../foo", "http://host/foo"], | 41 ["http://host/a?query#ref", "../../../foo", "http://host/foo"], |
| 42 // Query input | 42 // Query input |
| 43 ["http://host/a", "?foo=bar", "http://host/a?foo=bar"], | 43 ["http://host/a", "?foo=bar", "http://host/a?foo=bar"], |
| 44 ["http://host/a?x=y#z", "?", "http://host/a?"], | 44 ["http://host/a?x=y#z", "?", "http://host/a?"], |
| 45 ["http://host/a?x=y#z", "?foo=bar#com", "http://host/a?foo=bar#com"], | 45 ["http://host/a?x=y#z", "?foo=bar#com", "http://host/a?foo=bar#com"], |
| 46 // Ref input | 46 // Ref input |
| 47 ["http://host/a", "#ref", "http://host/a#ref"], | 47 ["http://host/a", "#ref", "http://host/a#ref"], |
| 48 ["http://host/a#b", "#", "http://host/a#"], | 48 ["http://host/a#b", "#", "http://host/a#"], |
| 49 ["http://host/a?foo=bar#hello", "#bye", "http://host/a?foo=bar#bye"], | 49 ["http://host/a?foo=bar#hello", "#bye", "http://host/a?foo=bar#bye"], |
| 50 // Non-hierarchical base: no relative handling. Relative input should | |
| 51 // error, and if a scheme is present, it should be treated as absolute. | |
| 52 ["data:foobar", "baz.html", ""], | |
| 53 ["data:foobar", "data:baz", "data:baz"], | |
| 54 ["data:foobar", "data:/base", "data:/base"], | |
| 55 // Non-hierarchical base: absolute input should succeed. | |
| 56 ["data:foobar", "http://host/", "http://host/"], | |
| 57 ["data:foobar", "http:host", "http://host/"], | |
| 58 // Invalid schemes should be treated as relative. | 50 // Invalid schemes should be treated as relative. |
| 59 ["http://foo/bar", "./asd:fgh", "http://foo/asd:fgh"], | 51 ["http://foo/bar", "./asd:fgh", "http://foo/asd:fgh"], |
| 60 ["http://foo/bar", ":foo", "http://foo/:foo"], | 52 ["http://foo/bar", ":foo", "http://foo/:foo"], |
| 61 ["http://foo/bar", " hello world", "http://foo/hello%20world"], | 53 ["http://foo/bar", " hello world", "http://foo/hello%20world"], |
| 62 ["data:asdf", ":foo", ""], | |
| 63 // We should treat semicolons like any other character in URL resolving | 54 // We should treat semicolons like any other character in URL resolving |
| 64 ["http://host/a", ";foo", "http://host/;foo"], | 55 ["http://host/a", ";foo", "http://host/;foo"], |
| 65 ["http://host/a;", ";foo", "http://host/;foo"], | 56 ["http://host/a;", ";foo", "http://host/;foo"], |
| 66 ["http://host/a", ";/../bar", "http://host/bar"], | 57 ["http://host/a", ";/../bar", "http://host/bar"], |
| 67 // Relative URLs can also be written as "//foo/bar" which is relative to | 58 // Relative URLs can also be written as "//foo/bar" which is relative to |
| 68 // the scheme. In this case, it would take the old scheme, so for http | 59 // the scheme. In this case, it would take the old scheme, so for http |
| 69 // the example would resolve to "http://foo/bar". | 60 // the example would resolve to "http://foo/bar". |
| 70 ["http://host/a", "//another", "http://another/"], | 61 ["http://host/a", "//another", "http://another/"], |
| 71 ["http://host/a", "//another/path?query#ref", "http://another/path?query#ref"]
, | 62 ["http://host/a", "//another/path?query#ref", "http://another/path?query#ref"]
, |
| 72 ["http://host/a", "///another/path", "http://another/path"], | 63 ["http://host/a", "///another/path", "http://another/path"], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 for (var i = 0; i < cases.length; ++i) { | 74 for (var i = 0; i < cases.length; ++i) { |
| 84 baseURL = cases[i][0]; | 75 baseURL = cases[i][0]; |
| 85 relativeURL = cases[i][1]; | 76 relativeURL = cases[i][1]; |
| 86 expectedURL = cases[i][2]; | 77 expectedURL = cases[i][2]; |
| 87 setBaseURL(baseURL); | 78 setBaseURL(baseURL); |
| 88 shouldBe("canonicalize('" + relativeURL + "')", | 79 shouldBe("canonicalize('" + relativeURL + "')", |
| 89 "'" + expectedURL + "'"); | 80 "'" + expectedURL + "'"); |
| 90 } | 81 } |
| 91 | 82 |
| 92 setBaseURL(originalBaseURL); | 83 setBaseURL(originalBaseURL); |
| OLD | NEW |