Skip to content

Commit

Permalink
Non-special URL path tests
Browse files Browse the repository at this point in the history
Some of these used to be part of #4406.

See also whatwg/url#212.
  • Loading branch information
annevk authored Jan 31, 2017
1 parent ca9e906 commit 37a9631
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 14 deletions.
51 changes: 39 additions & 12 deletions url/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"href": "a://example.net",
"new_value": "",
"expected": {
"href": "a://example.net/",
"href": "a://example.net",
"protocol": "a:"
}
},
{
"href": "a://example.net",
"new_value": "b",
"expected": {
"href": "b://example.net/",
"href": "b://example.net",
"protocol": "b:"
}
},
Expand All @@ -44,7 +44,7 @@
"href": "a://example.net",
"new_value": "B",
"expected": {
"href": "b://example.net/",
"href": "b://example.net",
"protocol": "b:"
}
},
Expand All @@ -53,7 +53,7 @@
"href": "a://example.net",
"new_value": "é",
"expected": {
"href": "a://example.net/",
"href": "a://example.net",
"protocol": "a:"
}
},
Expand All @@ -62,7 +62,7 @@
"href": "a://example.net",
"new_value": "0b",
"expected": {
"href": "a://example.net/",
"href": "a://example.net",
"protocol": "a:"
}
},
Expand All @@ -71,15 +71,15 @@
"href": "a://example.net",
"new_value": "+b",
"expected": {
"href": "a://example.net/",
"href": "a://example.net",
"protocol": "a:"
}
},
{
"href": "a://example.net",
"new_value": "bC0+-.",
"expected": {
"href": "bc0+-.://example.net/",
"href": "bc0+-.://example.net",
"protocol": "bc0+-.:"
}
},
Expand All @@ -88,7 +88,7 @@
"href": "a://example.net",
"new_value": "b,c",
"expected": {
"href": "a://example.net/",
"href": "a://example.net",
"protocol": "a:"
}
},
Expand All @@ -97,7 +97,7 @@
"href": "a://example.net",
"new_value": "",
"expected": {
"href": "a://example.net/",
"href": "a://example.net",
"protocol": "a:"
}
},
Expand Down Expand Up @@ -140,23 +140,23 @@
"href": "ssh://me@example.net",
"new_value": "http",
"expected": {
"href": "ssh://me@example.net/",
"href": "ssh://me@example.net",
"protocol": "ssh:"
}
},
{
"href": "ssh://me@example.net",
"new_value": "gopher",
"expected": {
"href": "ssh://me@example.net/",
"href": "ssh://me@example.net",
"protocol": "ssh:"
}
},
{
"href": "ssh://me@example.net",
"new_value": "file",
"expected": {
"href": "ssh://me@example.net/",
"href": "ssh://me@example.net",
"protocol": "ssh:"
}
},
Expand Down Expand Up @@ -1278,6 +1278,33 @@
"href": "http://example.net/%3F",
"pathname": "/%3F"
}
},
{
"comment": "# needs to be encoded",
"href": "http://example.net",
"new_value": "#",
"expected": {
"href": "http://example.net/%23",
"pathname": "/%23"
}
},
{
"comment": "? needs to be encoded, non-special scheme",
"href": "sc://example.net",
"new_value": "?",
"expected": {
"href": "sc://example.net/%3F",
"pathname": "/%3F"
}
},
{
"comment": "# needs to be encoded, non-special scheme",
"href": "sc://example.net",
"new_value": "#",
"expected": {
"href": "sc://example.net/%23",
"pathname": "/%23"
}
}
],
"search": [
Expand Down
150 changes: 148 additions & 2 deletions url/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,15 @@
{
"input": "foo://",
"base": "http://example.org/foo/bar",
"href": "foo:///",
"href": "foo://",
"origin": "null",
"protocol": "foo:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"pathname": "",
"search": "",
"hash": ""
},
Expand Down Expand Up @@ -4907,5 +4907,151 @@
"input": "http://#",
"base": "about:blank",
"failure": "true"
},
"# Non-special-URL path tests",
{
"input": "sc://ñ",
"base": "about:blank",
"href": "sc://%C3%B1",
"origin": "null",
"protocol": "sc:",
"username": "",
"password": "",
"host": "%C3%B1",
"hostname": "%C3%B1",
"port": "",
"pathname": "",
"search": "",
"hash": ""
},
{
"input": "sc://ñ?x",
"base": "about:blank",
"href": "sc://%C3%B1?x",
"origin": "null",
"protocol": "sc:",
"username": "",
"password": "",
"host": "%C3%B1",
"hostname": "%C3%B1",
"port": "",
"pathname": "",
"search": "?x",
"hash": ""
},
{
"input": "sc://ñ#x",
"base": "about:blank",
"href": "sc://%C3%B1#x",
"origin": "null",
"protocol": "sc:",
"username": "",
"password": "",
"host": "%C3%B1",
"hostname": "%C3%B1",
"port": "",
"pathname": "",
"search": "",
"hash": "#x"
},
{
"input": "#x",
"base": "sc://ñ",
"href": "sc://%C3%B1#x",
"origin": "null",
"protocol": "sc:",
"username": "",
"password": "",
"host": "%C3%B1",
"hostname": "%C3%B1",
"port": "",
"pathname": "",
"search": "",
"hash": "#x"
},
{
"input": "?x",
"base": "sc://ñ",
"href": "sc://%C3%B1?x",
"origin": "null",
"protocol": "sc:",
"username": "",
"password": "",
"host": "%C3%B1",
"hostname": "%C3%B1",
"port": "",
"pathname": "",
"search": "?x",
"hash": ""
},
{
"input": "sc://?",
"base": "about:blank",
"href": "sc://?",
"protocol": "sc:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "",
"search": "",
"hash": ""
},
{
"input": "sc://#",
"base": "about:blank",
"href": "sc://#",
"protocol": "sc:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "",
"search": "",
"hash": ""
},
{
"input": "///",
"base": "sc://x/",
"href": "sc:///",
"protocol": "sc:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "////",
"base": "sc://x/",
"href": "sc:////",
"protocol": "sc:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//",
"search": "",
"hash": ""
},
{
"input": "////x/",
"base": "sc://x/",
"href": "sc:////x/",
"protocol": "sc:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "//x/",
"search": "",
"hash": ""
}
]

0 comments on commit 37a9631

Please sign in to comment.