Skip to content

Commit

Permalink
url: make gopher behave like unrecognized schemes
Browse files Browse the repository at this point in the history
Per the change in web-platform-tests/wpt#19770.
  • Loading branch information
djc committed Aug 18, 2020
1 parent dce7c6e commit 2f204d0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 110 deletions.
2 changes: 1 addition & 1 deletion src/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn url_origin(url: &Url) -> Origin {
Err(_) => Origin::new_opaque(),
}
}
"ftp" | "gopher" | "http" | "https" | "ws" | "wss" => Origin::Tuple(
"ftp" | "http" | "https" | "ws" | "wss" => Origin::Tuple(
scheme.to_owned(),
url.host().unwrap().to_owned(),
url.port_or_known_default().unwrap(),
Expand Down
5 changes: 2 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl SchemeType {

pub fn from(s: &str) -> Self {
match s {
"http" | "https" | "ws" | "wss" | "ftp" | "gopher" => SchemeType::SpecialNotFile,
"http" | "https" | "ws" | "wss" | "ftp" => SchemeType::SpecialNotFile,
"file" => SchemeType::File,
_ => SchemeType::NotSpecial,
}
Expand All @@ -186,7 +186,6 @@ pub fn default_port(scheme: &str) -> Option<u16> {
"http" | "ws" => Some(80),
"https" | "wss" => Some(443),
"ftp" => Some(21),
"gopher" => Some(70),
_ => None,
}
}
Expand Down Expand Up @@ -1438,7 +1437,7 @@ impl<'a> Parser<'a> {
}

let encoding = match &self.serialization[..scheme_end as usize] {
"http" | "https" | "file" | "ftp" | "gopher" => self.query_encoding_override,
"http" | "https" | "file" | "ftp" => self.query_encoding_override,
_ => None,
};
let query_bytes = if let Some(o) = encoding {
Expand Down
16 changes: 0 additions & 16 deletions tests/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@
"protocol": "http:"
}
},
{
"href": "gopher://example.net:1234",
"new_value": "file",
"expected": {
"href": "gopher://example.net:1234/",
"protocol": "gopher:"
}
},
{
"href": "wss://x:[email protected]:1234",
"new_value": "file",
Expand Down Expand Up @@ -210,14 +202,6 @@
"protocol": "ssh:"
}
},
{
"href": "ssh://[email protected]",
"new_value": "gopher",
"expected": {
"href": "ssh://[email protected]",
"protocol": "ssh:"
}
},
{
"href": "ssh://[email protected]",
"new_value": "file",
Expand Down
90 changes: 0 additions & 90 deletions tests/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1073,21 +1073,6 @@
"search": "",
"hash": ""
},
{
"input": "gopher:/example.com/",
"base": "http://example.org/foo/bar",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "ws:/example.com/",
"base": "http://example.org/foo/bar",
Expand Down Expand Up @@ -1238,21 +1223,6 @@
"search": "",
"hash": ""
},
{
"input": "gopher:example.com/",
"base": "http://example.org/foo/bar",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "ws:example.com/",
"base": "http://example.org/foo/bar",
Expand Down Expand Up @@ -2508,36 +2478,6 @@
"search": "",
"hash": ""
},
{
"input": "gopher://foo:70/",
"base": "about:blank",
"href": "gopher://foo/",
"origin": "gopher://foo",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "foo",
"hostname": "foo",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "gopher://foo:443/",
"base": "about:blank",
"href": "gopher://foo:443/",
"origin": "gopher://foo:443",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "foo:443",
"hostname": "foo",
"port": "443",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "ws://foo:80/",
"base": "about:blank",
Expand Down Expand Up @@ -2747,21 +2687,6 @@
"search": "",
"hash": ""
},
{
"input": "gopher:/example.com/",
"base": "about:blank",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "ws:/example.com/",
"base": "about:blank",
Expand Down Expand Up @@ -2912,21 +2837,6 @@
"search": "",
"hash": ""
},
{
"input": "gopher:example.com/",
"base": "about:blank",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
},
{
"input": "ws:example.com/",
"base": "about:blank",
Expand Down

0 comments on commit 2f204d0

Please sign in to comment.