summaryrefslogtreecommitdiffstats
path: root/vendor/url/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/url/tests')
-rw-r--r--vendor/url/tests/data.rs30
-rw-r--r--vendor/url/tests/unit.rs136
-rw-r--r--vendor/url/tests/urltestdata.json1013
3 files changed, 1158 insertions, 21 deletions
diff --git a/vendor/url/tests/data.rs b/vendor/url/tests/data.rs
index f4001ca2b..dc4660b9b 100644
--- a/vendor/url/tests/data.rs
+++ b/vendor/url/tests/data.rs
@@ -15,29 +15,25 @@ use url::{quirks, Url};
#[test]
fn urltestdata() {
- let idna_skip_inputs = [
- "http://www.foo。bar.com",
- "http://Go.com",
- "http://你好你好",
- "https://faß.ExAmPlE/",
- "http://0Xc0.0250.01",
- "ftp://%e2%98%83",
- "https://%e2%98%83",
- "file://a\u{ad}b/p",
- "file://a%C2%ADb/p",
- "http://GOO\u{200b}\u{2060}\u{feff}goo.com",
- ];
-
// Copied from https://github.com/web-platform-tests/wpt/blob/master/url/
let mut json = Value::from_str(include_str!("urltestdata.json"))
.expect("JSON parse error in urltestdata.json");
let mut passed = true;
+ let mut skip_next = false;
for entry in json.as_array_mut().unwrap() {
if entry.is_string() {
+ if entry.as_str().unwrap() == "skip next" {
+ skip_next = true;
+ }
continue; // ignore comments
}
+ if skip_next {
+ skip_next = false;
+ continue;
+ }
+
let maybe_base = entry
.take_key("base")
.expect("missing base key")
@@ -45,12 +41,6 @@ fn urltestdata() {
let input = entry.take_string("input");
let failure = entry.take_key("failure").is_some();
- {
- if idna_skip_inputs.contains(&input.as_str()) {
- continue;
- }
- }
-
let res = if let Some(base) = maybe_base {
let base = match Url::parse(&base) {
Ok(base) => base,
@@ -228,7 +218,7 @@ fn get<'a>(url: &'a Url, attr: &str) -> &'a str {
}
#[allow(clippy::unit_arg)]
-fn set<'a>(url: &'a mut Url, attr: &str, new: &str) {
+fn set(url: &mut Url, attr: &str, new: &str) {
let _ = match attr {
"protocol" => quirks::set_protocol(url, new),
"username" => quirks::set_username(url, new),
diff --git a/vendor/url/tests/unit.rs b/vendor/url/tests/unit.rs
index 55ff59ada..6cb0f37fe 100644
--- a/vendor/url/tests/unit.rs
+++ b/vendor/url/tests/unit.rs
@@ -35,6 +35,17 @@ fn test_relative_empty() {
}
#[test]
+fn test_strip_trailing_spaces_from_opaque_path() {
+ let mut url: Url = "data:space ?query".parse().unwrap();
+ url.set_query(None);
+ assert_eq!(url.as_str(), "data:space");
+
+ let mut url: Url = "data:space #hash".parse().unwrap();
+ url.set_fragment(None);
+ assert_eq!(url.as_str(), "data:space");
+}
+
+#[test]
fn test_set_empty_host() {
let mut base: Url = "moz://foo:bar@servo/baz".parse().unwrap();
base.set_username("").unwrap();
@@ -54,6 +65,30 @@ fn test_set_empty_host() {
}
#[test]
+fn test_set_empty_username_and_password() {
+ let mut base: Url = "moz://foo:bar@servo/baz".parse().unwrap();
+ base.set_username("").unwrap();
+ assert_eq!(base.as_str(), "moz://:bar@servo/baz");
+
+ base.set_password(Some("")).unwrap();
+ assert_eq!(base.as_str(), "moz://servo/baz");
+
+ base.set_password(None).unwrap();
+ assert_eq!(base.as_str(), "moz://servo/baz");
+}
+
+#[test]
+fn test_set_empty_password() {
+ let mut base: Url = "moz://foo:bar@servo/baz".parse().unwrap();
+
+ base.set_password(Some("")).unwrap();
+ assert_eq!(base.as_str(), "moz://foo@servo/baz");
+
+ base.set_password(None).unwrap();
+ assert_eq!(base.as_str(), "moz://foo@servo/baz");
+}
+
+#[test]
fn test_set_empty_hostname() {
use url::quirks;
let mut base: Url = "moz://foo@servo/baz".parse().unwrap();
@@ -71,6 +106,17 @@ fn test_set_empty_hostname() {
assert_eq!(base.as_str(), "moz:///baz");
}
+#[test]
+fn test_set_empty_query() {
+ let mut base: Url = "moz://example.com/path?query".parse().unwrap();
+
+ base.set_query(Some(""));
+ assert_eq!(base.as_str(), "moz://example.com/path?");
+
+ base.set_query(None);
+ assert_eq!(base.as_str(), "moz://example.com/path");
+}
+
macro_rules! assert_from_file_path {
($path: expr) => {
assert_from_file_path!($path, $path)
@@ -944,6 +990,16 @@ fn no_panic() {
}
#[test]
+fn test_null_host_with_leading_empty_path_segment() {
+ // since Note in item 3 of URL serializing in the URL Standard
+ // https://url.spec.whatwg.org/#url-serializing
+ let url = Url::parse("m:/.//\\").unwrap();
+ let encoded = url.as_str();
+ let reparsed = Url::parse(encoded).unwrap();
+ assert_eq!(reparsed, url);
+}
+
+#[test]
fn pop_if_empty_in_bounds() {
let mut url = Url::parse("m://").unwrap();
let mut segments = url.path_segments_mut().unwrap();
@@ -1162,3 +1218,83 @@ fn test_make_relative() {
assert_eq!(make_relative, None, "base: {}, uri: {}", base, uri);
}
}
+
+#[test]
+fn test_has_authority() {
+ let url = Url::parse("mailto:joe@example.com").unwrap();
+ assert!(!url.has_authority());
+ let url = Url::parse("unix:/run/foo.socket").unwrap();
+ assert!(!url.has_authority());
+ let url = Url::parse("file:///tmp/foo").unwrap();
+ assert!(url.has_authority());
+ let url = Url::parse("http://example.com/tmp/foo").unwrap();
+ assert!(url.has_authority());
+}
+
+#[test]
+fn test_authority() {
+ let url = Url::parse("mailto:joe@example.com").unwrap();
+ assert_eq!(url.authority(), "");
+ let url = Url::parse("unix:/run/foo.socket").unwrap();
+ assert_eq!(url.authority(), "");
+ let url = Url::parse("file:///tmp/foo").unwrap();
+ assert_eq!(url.authority(), "");
+ let url = Url::parse("http://example.com/tmp/foo").unwrap();
+ assert_eq!(url.authority(), "example.com");
+ let url = Url::parse("ftp://127.0.0.1:21/").unwrap();
+ assert_eq!(url.authority(), "127.0.0.1");
+ let url = Url::parse("ftp://user@127.0.0.1:2121/").unwrap();
+ assert_eq!(url.authority(), "user@127.0.0.1:2121");
+ let url = Url::parse("https://:@example.com/").unwrap();
+ assert_eq!(url.authority(), "example.com");
+ let url = Url::parse("https://:password@[::1]:8080/").unwrap();
+ assert_eq!(url.authority(), ":password@[::1]:8080");
+ let url = Url::parse("gopher://user:@àlex.example.com:70").unwrap();
+ assert_eq!(url.authority(), "user@%C3%A0lex.example.com:70");
+ let url = Url::parse("irc://àlex:àlex@àlex.рф.example.com:6667/foo").unwrap();
+ assert_eq!(
+ url.authority(),
+ "%C3%A0lex:%C3%A0lex@%C3%A0lex.%D1%80%D1%84.example.com:6667"
+ );
+ let url = Url::parse("https://àlex:àlex@àlex.рф.example.com:443/foo").unwrap();
+ assert_eq!(
+ url.authority(),
+ "%C3%A0lex:%C3%A0lex@xn--lex-8ka.xn--p1ai.example.com"
+ );
+}
+
+#[test]
+/// https://github.com/servo/rust-url/issues/838
+fn test_file_with_drive() {
+ let s1 = "fIlE:p:?../";
+ let url = url::Url::parse(s1).unwrap();
+ assert_eq!(url.to_string(), "file:///p:?../");
+ assert_eq!(url.path(), "/p:");
+
+ let testcases = [
+ ("a", "file:///p:/a"),
+ ("", "file:///p:?../"),
+ ("?x", "file:///p:?x"),
+ (".", "file:///p:/"),
+ ("..", "file:///p:/"),
+ ("../", "file:///p:/"),
+ ];
+
+ for case in &testcases {
+ let url2 = url::Url::join(&url, case.0).unwrap();
+ assert_eq!(url2.to_string(), case.1);
+ }
+}
+
+#[test]
+/// Similar to test_file_with_drive, but with a path
+/// that could be confused for a drive.
+fn test_file_with_drive_and_path() {
+ let s1 = "fIlE:p:/x|?../";
+ let url = url::Url::parse(s1).unwrap();
+ assert_eq!(url.to_string(), "file:///p:/x|?../");
+ assert_eq!(url.path(), "/p:/x|");
+ let s2 = "a";
+ let url2 = url::Url::join(&url, s2).unwrap();
+ assert_eq!(url2.to_string(), "file:///p:/a");
+}
diff --git a/vendor/url/tests/urltestdata.json b/vendor/url/tests/urltestdata.json
index 4265f5928..53d036886 100644
--- a/vendor/url/tests/urltestdata.json
+++ b/vendor/url/tests/urltestdata.json
@@ -1,6 +1,5 @@
[
"# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/segments.js",
- "# AS OF https://github.com/web-platform-tests/wpt/commit/2a64dae4641fbd61bd4257df460e188f425b492e",
{
"input": "http://example\t.\norg",
"base": "http://example.org/foo/bar",
@@ -966,6 +965,11 @@
"hash": ""
},
{
+ "input": "http://[::127.0.0.1.]",
+ "base": "http://example.org/foo/bar",
+ "failure": true
+ },
+ {
"input": "http://[0:0:0:0:0:0:13.1.68.3]",
"base": "http://example.org/foo/bar",
"href": "http://[::d01:4403]/",
@@ -3918,6 +3922,22 @@
"search": "",
"hash": ""
},
+ "Non-special domains with empty labels",
+ {
+ "input": "h://.",
+ "base": "about:blank",
+ "href": "h://.",
+ "origin": "null",
+ "protocol": "h:",
+ "username": "",
+ "password": "",
+ "host": ".",
+ "hostname": ".",
+ "port": "",
+ "pathname": "",
+ "search": "",
+ "hash": ""
+ },
"Broken IPv6",
{
"input": "http://[www.google.com]/",
@@ -3945,10 +3965,30 @@
"failure": true
},
{
+ "input": "http://[::.1.2]",
+ "base": "http://other.com/",
+ "failure": true
+ },
+ {
"input": "http://[::1.]",
"base": "http://other.com/",
"failure": true
},
+ {
+ "input": "http://[::.1]",
+ "base": "http://other.com/",
+ "failure": true
+ },
+ {
+ "input": "http://[::%31]",
+ "base": "http://other.com/",
+ "failure": true
+ },
+ {
+ "input": "http://%5B::1]",
+ "base": "http://other.com/",
+ "failure": true
+ },
"Misc Unicode",
{
"input": "http://foo:💩@example.com/bar",
@@ -5895,6 +5935,21 @@
"search": "",
"hash": ""
},
+ "skip next",
+ {
+ "input": "/",
+ "base": "file://h/C:/a/b",
+ "href": "file://h/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "h",
+ "hostname": "h",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
{
"input": "/",
"base": "file://h/a/b",
@@ -6050,6 +6105,96 @@
"hash": "#x"
},
"# File URLs and many (back)slashes",
+ "skip next",
+ {
+ "input": "file:\\\\//",
+ "base": "about:blank",
+ "href": "file:////",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:\\\\\\\\",
+ "base": "about:blank",
+ "href": "file:////",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:\\\\\\\\?fox",
+ "base": "about:blank",
+ "href": "file:////?fox",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "?fox",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:\\\\\\\\#guppy",
+ "base": "about:blank",
+ "href": "file:////#guppy",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": "#guppy"
+ },
+ "skip next",
+ {
+ "input": "file://spider///",
+ "base": "about:blank",
+ "href": "file://spider///",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "spider",
+ "hostname": "spider",
+ "port": "",
+ "pathname": "///",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:\\\\localhost//",
+ "base": "about:blank",
+ "href": "file:////",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
{
"input": "file:///localhost//cat",
"base": "about:blank",
@@ -6064,6 +6209,51 @@
"search": "",
"hash": ""
},
+ "skip next",
+ {
+ "input": "file://\\/localhost//cat",
+ "base": "about:blank",
+ "href": "file:////localhost//cat",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//localhost//cat",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file://localhost//a//../..//",
+ "base": "about:blank",
+ "href": "file://///",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "///",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "/////mouse",
+ "base": "file:///elephant",
+ "href": "file://///mouse",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "///mouse",
+ "search": "",
+ "hash": ""
+ },
{
"input": "\\//pig",
"base": "file://lion/",
@@ -6078,6 +6268,51 @@
"search": "",
"hash": ""
},
+ "skip next",
+ {
+ "input": "\\/localhost//pig",
+ "base": "file://lion/",
+ "href": "file:////pig",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//pig",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "//localhost//pig",
+ "base": "file://lion/",
+ "href": "file:////pig",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//pig",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "/..//localhost//pig",
+ "base": "file://lion/",
+ "href": "file://lion//localhost//pig",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "lion",
+ "hostname": "lion",
+ "port": "",
+ "pathname": "//localhost//pig",
+ "search": "",
+ "hash": ""
+ },
{
"input": "file://",
"base": "file://ape/",
@@ -6122,6 +6357,111 @@
"hash": ""
},
"# Windows drive letter handling with the 'file:' base URL",
+ "skip next",
+ {
+ "input": "C|",
+ "base": "file://host/dir/file",
+ "href": "file://host/C:",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "C|",
+ "base": "file://host/D:/dir1/dir2/file",
+ "href": "file://host/C:",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "C|#",
+ "base": "file://host/dir/file",
+ "href": "file://host/C:#",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "C|?",
+ "base": "file://host/dir/file",
+ "href": "file://host/C:?",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "C|/",
+ "base": "file://host/dir/file",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "C|\n/",
+ "base": "file://host/dir/file",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "C|\\",
+ "base": "file://host/dir/file",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
{
"input": "C",
"base": "file://host/dir/file",
@@ -6193,7 +6533,130 @@
"search": "",
"hash": ""
},
+ "skip next",
+ {
+ "input": "/c:/foo/bar",
+ "base": "file://host/path",
+ "href": "file://host/c:/foo/bar",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/c:/foo/bar",
+ "search": "",
+ "hash": ""
+ },
+ "# Do not drop the host in the presence of a drive letter",
+ "skip next",
+ {
+ "input": "file://example.net/C:/",
+ "base": "about:blank",
+ "href": "file://example.net/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "example.net",
+ "hostname": "example.net",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file://1.2.3.4/C:/",
+ "base": "about:blank",
+ "href": "file://1.2.3.4/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "1.2.3.4",
+ "hostname": "1.2.3.4",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file://[1::8]/C:/",
+ "base": "about:blank",
+ "href": "file://[1::8]/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "[1::8]",
+ "hostname": "[1::8]",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "# Copy the host from the base URL in the following cases",
+ "skip next",
+ {
+ "input": "C|/",
+ "base": "file://host/",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "/C:/",
+ "base": "file://host/",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:C:/",
+ "base": "file://host/",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:/C:/",
+ "base": "file://host/",
+ "href": "file://host/C:/",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "host",
+ "hostname": "host",
+ "port": "",
+ "pathname": "/C:/",
+ "search": "",
+ "hash": ""
+ },
"# Copy the empty host from the input in the following cases",
+ "skip next",
{
"input": "//C:/",
"base": "file://host/",
@@ -6449,6 +6912,51 @@
"inputCanBeRelative": true
},
"# Additional file URL tests for (https://github.com/whatwg/url/issues/405)",
+ "skip next",
+ {
+ "input": "file://localhost//a//../..//foo",
+ "base": "about:blank",
+ "href": "file://///foo",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "///foo",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file://localhost////foo",
+ "base": "about:blank",
+ "href": "file://////foo",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "////foo",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:////foo",
+ "base": "about:blank",
+ "href": "file:////foo",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//foo",
+ "search": "",
+ "hash": ""
+ },
{
"input": "file:///one/two",
"base": "file:///",
@@ -6463,6 +6971,21 @@
"search": "",
"hash": ""
},
+ "skip next",
+ {
+ "input": "file:////one/two",
+ "base": "file:///",
+ "href": "file:////one/two",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//one/two",
+ "search": "",
+ "hash": ""
+ },
{
"input": "//one/two",
"base": "file:///",
@@ -6491,6 +7014,67 @@
"search": "",
"hash": ""
},
+ "skip next",
+ {
+ "input": "////one/two",
+ "base": "file:///",
+ "href": "file:////one/two",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//one/two",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:///.//",
+ "base": "file:////",
+ "href": "file:////",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
+ "File URL tests for https://github.com/whatwg/url/issues/549",
+ "skip next",
+ {
+ "input": "file:.//p",
+ "base": "about:blank",
+ "href": "file:////p",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//p",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "file:/.//p",
+ "base": "about:blank",
+ "href": "file:////p",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//p",
+ "search": "",
+ "hash": ""
+ },
"# IPv6 tests",
{
"input": "http://[1:0::]",
@@ -6902,6 +7486,191 @@
"search": "",
"hash": ""
},
+ "Serialize /. in path",
+ {
+ "input": "non-spec:/.//",
+ "base": "about:blank",
+ "href": "non-spec:/.//",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "non-spec:/..//",
+ "base": "about:blank",
+ "href": "non-spec:/.//",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "non-spec:/a/..//",
+ "base": "about:blank",
+ "href": "non-spec:/.//",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "non-spec:/.//path",
+ "base": "about:blank",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "non-spec:/..//path",
+ "base": "about:blank",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "non-spec:/a/..//path",
+ "base": "about:blank",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ "skip next",
+ {
+ "input": "/.//path",
+ "base": "non-spec:/p",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "/..//path",
+ "base": "non-spec:/p",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "..//path",
+ "base": "non-spec:/p",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "a/..//path",
+ "base": "non-spec:/p",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "",
+ "base": "non-spec:/..//p",
+ "href": "non-spec:/.//p",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//p",
+ "search": "",
+ "hash": ""
+ },
+ {
+ "input": "path",
+ "base": "non-spec:/..//p",
+ "href": "non-spec:/.//path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "//path",
+ "search": "",
+ "hash": ""
+ },
+ "Do not serialize /. in path",
+ {
+ "input": "../path",
+ "base": "non-spec:/.//p",
+ "href": "non-spec:/path",
+ "protocol": "non-spec:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "/path",
+ "search": "",
+ "hash": ""
+ },
"# percent encoded hosts in non-special-URLs",
{
"input": "non-special://%E2%80%A0/",
@@ -7419,6 +8188,21 @@
"search": "",
"hash": ""
},
+ "IDNA hostnames which get mapped to 'localhost'",
+ {
+ "input": "file://loC𝐀𝐋𝐇𝐨𝐬𝐭/usr/bin",
+ "base": "about:blank",
+ "href": "file:///usr/bin",
+ "protocol": "file:",
+ "username": "",
+ "password": "",
+ "host": "",
+ "hostname": "",
+ "port": "",
+ "pathname": "/usr/bin",
+ "search": "",
+ "hash": ""
+ },
"Empty host after the domain to ASCII",
{
"input": "file://\u00ad/p",
@@ -7904,5 +8688,232 @@
"input": "http://💩.123/",
"base": "about:blank",
"failure": true
+ },
+ "U+0000 and U+FFFF in various places",
+ {
+ "input": "https://\u0000y",
+ "base": "about:blank",
+ "failure": true
+ },
+ {
+ "input": "https://x/\u0000y",
+ "base": "about:blank",
+ "hash": "",
+ "host": "x",
+ "hostname": "x",
+ "href": "https://x/%00y",
+ "password": "",
+ "pathname": "/%00y",
+ "port": "",
+ "protocol": "https:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "https://x/?\u0000y",
+ "base": "about:blank",
+ "hash": "",
+ "host": "x",
+ "hostname": "x",
+ "href": "https://x/?%00y",
+ "password": "",
+ "pathname": "/",
+ "port": "",
+ "protocol": "https:",
+ "search": "?%00y",
+ "username": ""
+ },
+ {
+ "input": "https://x/?#\u0000y",
+ "base": "about:blank",
+ "hash": "#%00y",
+ "host": "x",
+ "hostname": "x",
+ "href": "https://x/?#%00y",
+ "password": "",
+ "pathname": "/",
+ "port": "",
+ "protocol": "https:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "https://\uFFFFy",
+ "base": "about:blank",
+ "failure": true
+ },
+ {
+ "input": "https://x/\uFFFFy",
+ "base": "about:blank",
+ "hash": "",
+ "host": "x",
+ "hostname": "x",
+ "href": "https://x/%EF%BF%BFy",
+ "password": "",
+ "pathname": "/%EF%BF%BFy",
+ "port": "",
+ "protocol": "https:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "https://x/?\uFFFFy",
+ "base": "about:blank",
+ "hash": "",
+ "host": "x",
+ "hostname": "x",
+ "href": "https://x/?%EF%BF%BFy",
+ "password": "",
+ "pathname": "/",
+ "port": "",
+ "protocol": "https:",
+ "search": "?%EF%BF%BFy",
+ "username": ""
+ },
+ {
+ "input": "https://x/?#\uFFFFy",
+ "base": "about:blank",
+ "hash": "#%EF%BF%BFy",
+ "host": "x",
+ "hostname": "x",
+ "href": "https://x/?#%EF%BF%BFy",
+ "password": "",
+ "pathname": "/",
+ "port": "",
+ "protocol": "https:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "non-special:\u0000y",
+ "base": "about:blank",
+ "hash": "",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:%00y",
+ "password": "",
+ "pathname": "%00y",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "non-special:x/\u0000y",
+ "base": "about:blank",
+ "hash": "",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:x/%00y",
+ "password": "",
+ "pathname": "x/%00y",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "non-special:x/?\u0000y",
+ "base": "about:blank",
+ "hash": "",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:x/?%00y",
+ "password": "",
+ "pathname": "x/",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "?%00y",
+ "username": ""
+ },
+ {
+ "input": "non-special:x/?#\u0000y",
+ "base": "about:blank",
+ "hash": "#%00y",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:x/?#%00y",
+ "password": "",
+ "pathname": "x/",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "non-special:\uFFFFy",
+ "base": "about:blank",
+ "hash": "",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:%EF%BF%BFy",
+ "password": "",
+ "pathname": "%EF%BF%BFy",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "non-special:x/\uFFFFy",
+ "base": "about:blank",
+ "hash": "",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:x/%EF%BF%BFy",
+ "password": "",
+ "pathname": "x/%EF%BF%BFy",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "non-special:x/?\uFFFFy",
+ "base": "about:blank",
+ "hash": "",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:x/?%EF%BF%BFy",
+ "password": "",
+ "pathname": "x/",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "?%EF%BF%BFy",
+ "username": ""
+ },
+ {
+ "input": "non-special:x/?#\uFFFFy",
+ "base": "about:blank",
+ "hash": "#%EF%BF%BFy",
+ "host": "",
+ "hostname": "",
+ "href": "non-special:x/?#%EF%BF%BFy",
+ "password": "",
+ "pathname": "x/",
+ "port": "",
+ "protocol": "non-special:",
+ "search": "",
+ "username": ""
+ },
+ {
+ "input": "",
+ "base": "about:blank",
+ "failure": true
+ },
+ {
+ "input": "https://example.com/\"quoted\"",
+ "base": "about:blank",
+ "hash": "",
+ "host": "example.com",
+ "hostname": "example.com",
+ "href": "https://example.com/%22quoted%22",
+ "origin": "https://example.com",
+ "password": "",
+ "pathname": "/%22quoted%22",
+ "port": "",
+ "protocol": "https:",
+ "search": "",
+ "username": ""
}
]