|
@@ -83,6 +83,15 @@
|
|
|
"protocol": "bc0+-.:"
|
|
"protocol": "bc0+-.:"
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Only some punctuation is acceptable",
|
|
|
|
|
+ "href": "a://example.net",
|
|
|
|
|
+ "new_value": "b,c",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "a://example.net/",
|
|
|
|
|
+ "protocol": "a:"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
"comment": "Non-ASCII is rejected",
|
|
"comment": "Non-ASCII is rejected",
|
|
|
"href": "a://example.net",
|
|
"href": "a://example.net",
|
|
@@ -296,7 +305,314 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
- "host": [],
|
|
|
|
|
|
|
+ "host": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Cannot-be-a-base means no host",
|
|
|
|
|
+ "href": "mailto:me@example.net",
|
|
|
|
|
+ "new_value": "example.com",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "mailto:me@example.net",
|
|
|
|
|
+ "host": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Cannot-be-a-base means no password",
|
|
|
|
|
+ "href": "data:text/plain,Stuff",
|
|
|
|
|
+ "new_value": "example.net",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "data:text/plain,Stuff",
|
|
|
|
|
+ "host": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "href": "http://example.net",
|
|
|
|
|
+ "new_value": "example.com:8080",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Port number is unchanged if not specified in the new value",
|
|
|
|
|
+ "href": "http://example.net:8080",
|
|
|
|
|
+ "new_value": "example.com",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Port number is removed if empty in the new value: https://github.com/whatwg/url/pull/113",
|
|
|
|
|
+ "href": "http://example.net:8080",
|
|
|
|
|
+ "new_value": "example.com:",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Port number can be removed",
|
|
|
|
|
+ "href": "http://example.net:8080",
|
|
|
|
|
+ "new_value": "example.com:",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "The empty host is not valid for special schemes",
|
|
|
|
|
+ "href": "http://example.net",
|
|
|
|
|
+ "new_value": "",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.net/",
|
|
|
|
|
+ "host": "example.net"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "The empty host is OK for non-special schemes",
|
|
|
|
|
+ "href": "view-source+http://example.net/foo",
|
|
|
|
|
+ "new_value": "",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "view-source+http:///foo",
|
|
|
|
|
+ "host": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Path-only URLs can gain a host",
|
|
|
|
|
+ "href": "a:/foo",
|
|
|
|
|
+ "new_value": "example.net",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "a://example.net/foo",
|
|
|
|
|
+ "host": "example.net"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Path-only URLs can gain a host",
|
|
|
|
|
+ "href": "a:/foo",
|
|
|
|
|
+ "new_value": "example.net",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "a://example.net/foo",
|
|
|
|
|
+ "host": "example.net"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "IPv4 address syntax is normalized",
|
|
|
|
|
+ "href": "http://example.net",
|
|
|
|
|
+ "new_value": "0x7F000001:8080",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://127.0.0.1:8080/",
|
|
|
|
|
+ "host": "127.0.0.1:8080",
|
|
|
|
|
+ "hostname": "127.0.0.1",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "IPv6 address syntax is normalized",
|
|
|
|
|
+ "href": "http://example.net",
|
|
|
|
|
+ "new_value": "[::0:01]:2",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://[::1]:2/",
|
|
|
|
|
+ "host": "[::1]:2",
|
|
|
|
|
+ "hostname": "[::1]",
|
|
|
|
|
+ "port": "2"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Default port number is removed",
|
|
|
|
|
+ "href": "http://example.net",
|
|
|
|
|
+ "new_value": "example.com:80",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Default port number is removed",
|
|
|
|
|
+ "href": "https://example.net",
|
|
|
|
|
+ "new_value": "example.com:443",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "https://example.com/",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Default port number is only removed for the relevant scheme",
|
|
|
|
|
+ "href": "https://example.net",
|
|
|
|
|
+ "new_value": "example.com:80",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "https://example.com:80/",
|
|
|
|
|
+ "host": "example.com:80",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "80"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a / delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com/stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/path",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a / delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080/stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a ? delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com?stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/path",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a ? delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080?stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a # delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com#stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/path",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a # delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080#stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a \\ delimiter is ignored",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com\\stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/path",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Stuff after a \\ delimiter is ignored for special schemes",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080\\stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "\\ is not a delimiter for non-special schemes, and it’s invalid in a domain",
|
|
|
|
|
+ "href": "view-source+http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com\\stuff",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "view-source+http://example.net/path",
|
|
|
|
|
+ "host": "example.net",
|
|
|
|
|
+ "hostname": "example.net",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
|
|
|
|
|
+ "href": "view-source+http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080stuff2",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "view-source+http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080stuff2",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:8080+2",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:8080/path",
|
|
|
|
|
+ "host": "example.com:8080",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "8080"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Port numbers are 16 bit integers",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:65535",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com:65535/path",
|
|
|
|
|
+ "host": "example.com:65535",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": "65535"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "comment": "Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though.",
|
|
|
|
|
+ "href": "http://example.net/path",
|
|
|
|
|
+ "new_value": "example.com:65536",
|
|
|
|
|
+ "expected": {
|
|
|
|
|
+ "href": "http://example.com/path",
|
|
|
|
|
+ "host": "example.com",
|
|
|
|
|
+ "hostname": "example.com",
|
|
|
|
|
+ "port": ""
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
"hostname": [],
|
|
"hostname": [],
|
|
|
"port": [],
|
|
"port": [],
|
|
|
"pathname": [],
|
|
"pathname": [],
|