Skip to content

Commit

Permalink
url: remove gopher from special schemes
Browse files Browse the repository at this point in the history
Refs: #33315
Refs: whatwg/url@d589670
Refs: whatwg/url@7ae1c69

PR-URL: #33325
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
targos committed Jun 6, 2020
1 parent e0586d0 commit 0d08d5a
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 37 deletions.
22 changes: 20 additions & 2 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ If the value assigned to the `href` property is not a valid URL, a `TypeError`
will be thrown.

#### `url.origin`
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/33325
description: The scheme "gopher" is no longer special and `url.origin` now
returns `'null'` for it.
-->

* {string}

Expand Down Expand Up @@ -305,6 +312,12 @@ to percent-encode may vary somewhat from what the [`url.parse()`][] and
[`url.format()`][] methods would produce.

#### `url.port`
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/33325
description: The scheme "gopher" is no longer special.
-->

* {string}

Expand All @@ -322,7 +335,6 @@ the protocol/scheme:
| -------- | ---- |
| "ftp" | 21 |
| "file" | |
| "gopher" | 70 |
| "http" | 80 |
| "https" | 443 |
| "ws" | 80 |
Expand Down Expand Up @@ -407,6 +419,12 @@ console.log(myURL.href);
Invalid URL protocol values assigned to the `protocol` property are ignored.

##### Special Schemes
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/33325
description: The scheme "gopher" is no longer special.
-->

The [WHATWG URL Standard][] considers a handful of URL protocol schemes to be
_special_ in terms of how they are parsed and serialized. When a URL is
Expand Down Expand Up @@ -444,7 +462,7 @@ console.log(u.href);
```

According to the WHATWG URL Standard, special protocol schemes are `ftp`,
`file`, `gopher`, `http`, `https`, `ws`, and `wss`.
`file`, `http`, `https`, `ws`, and `wss`.

#### `url.search`

Expand Down
1 change: 0 additions & 1 deletion lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ ObjectDefineProperties(URL.prototype, {
}
return kOpaqueOrigin;
case 'ftp:':
case 'gopher:':
case 'http:':
case 'https:':
case 'ws:':
Expand Down
1 change: 0 additions & 1 deletion src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ constexpr size_t kFsStatsBufferLength =
V(unknown_string, "<unknown>") \
V(url_special_ftp_string, "ftp:") \
V(url_special_file_string, "file:") \
V(url_special_gopher_string, "gopher:") \
V(url_special_http_string, "http:") \
V(url_special_https_string, "https:") \
V(url_special_ws_string, "ws:") \
Expand Down
1 change: 0 additions & 1 deletion src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ std::string PercentDecode(const char* input, size_t len) {
#define SPECIALS(XX) \
XX(ftp, 21, "ftp:") \
XX(file, -1, "file:") \
XX(gopher, 70, "gopher:") \
XX(http, 80, "http:") \
XX(https, 443, "https:") \
XX(ws, 80, "ws:") \
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Last update:

- console: https://github.com/web-platform-tests/wpt/tree/9786a4b131/console
- encoding: https://github.com/web-platform-tests/wpt/tree/5059d2c777/encoding
- url: https://github.com/web-platform-tests/wpt/tree/418f7fabeb/url
- url: https://github.com/web-platform-tests/wpt/tree/43feb7f612/url
- resources: https://github.com/web-platform-tests/wpt/tree/e1fddfbf80/resources
- interfaces: https://github.com/web-platform-tests/wpt/tree/8ada332aea/interfaces
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/0c3bed38df/html/webappapis/microtask-queuing
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/wpt/url/failure.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!doctype html>
<meta charset=utf-8>
<title>Test URL parser failure consistency</title>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/wpt/url/resources/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"href": "gopher://example.net:1234",
"new_value": "file",
"expected": {
"href": "gopher://example.net:1234/",
"href": "gopher://example.net:1234",
"protocol": "gopher:"
}
},
Expand Down Expand Up @@ -212,7 +212,7 @@
},
{
"href": "ssh://me@example.net",
"new_value": "gopher",
"new_value": "https",
"expected": {
"href": "ssh://me@example.net",
"protocol": "ssh:"
Expand Down Expand Up @@ -597,7 +597,7 @@
}
},
{
"comment": "Cannot-be-a-base means no password",
"comment": "Cannot-be-a-base means no host",
"href": "data:text/plain,Stuff",
"new_value": "example.net",
"expected": {
Expand Down Expand Up @@ -1074,7 +1074,7 @@
}
},
{
"comment": "Cannot-be-a-base means no password",
"comment": "Cannot-be-a-base means no host",
"href": "data:text/plain,Stuff",
"new_value": "example.net",
"expected": {
Expand Down
50 changes: 25 additions & 25 deletions test/fixtures/wpt/url/resources/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1076,15 +1076,15 @@
{
"input": "gopher:/example.com/",
"base": "http://example.org/foo/bar",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"href": "gopher:/example.com/",
"origin": "null",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"pathname": "/example.com/",
"search": "",
"hash": ""
},
Expand Down Expand Up @@ -1241,15 +1241,15 @@
{
"input": "gopher:example.com/",
"base": "http://example.org/foo/bar",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"href": "gopher:example.com/",
"origin": "null",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"pathname": "example.com/",
"search": "",
"hash": ""
},
Expand Down Expand Up @@ -2511,14 +2511,14 @@
{
"input": "gopher://foo:70/",
"base": "about:blank",
"href": "gopher://foo/",
"origin": "gopher://foo",
"href": "gopher://foo:70/",
"origin": "null",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "foo",
"host": "foo:70",
"hostname": "foo",
"port": "",
"port": "70",
"pathname": "/",
"search": "",
"hash": ""
Expand All @@ -2527,7 +2527,7 @@
"input": "gopher://foo:443/",
"base": "about:blank",
"href": "gopher://foo:443/",
"origin": "gopher://foo:443",
"origin": "null",
"protocol": "gopher:",
"username": "",
"password": "",
Expand Down Expand Up @@ -2750,15 +2750,15 @@
{
"input": "gopher:/example.com/",
"base": "about:blank",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"href": "gopher:/example.com/",
"origin": "null",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"pathname": "/example.com/",
"search": "",
"hash": ""
},
Expand Down Expand Up @@ -2915,15 +2915,15 @@
{
"input": "gopher:example.com/",
"base": "about:blank",
"href": "gopher://example.com/",
"origin": "gopher://example.com",
"href": "gopher:example.com/",
"origin": "null",
"protocol": "gopher:",
"username": "",
"password": "",
"host": "example.com",
"hostname": "example.com",
"host": "",
"hostname": "",
"port": "",
"pathname": "/",
"pathname": "example.com/",
"search": "",
"hash": ""
},
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"path": "encoding"
},
"url": {
"commit": "418f7fabebeeb642e79e05b48ffde1a601c7e058",
"commit": "43feb7f612fe9160639e09a47933a29834904d69",
"path": "url"
},
"resources": {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-whatwg-url-custom-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ assert.strictEqual(url.searchParams, oldParams);
{ expected: 'https://whatwg.org',
url: 'blob:https://whatwg.org/d0360e2f-caee-469f-9a2f-87d5b0456f6f' },
{ expected: 'ftp://example.org', url: 'ftp://example.org/foo' },
{ expected: 'gopher://gopher.quux.org', url: 'gopher://gopher.quux.org/1/' },
{ expected: 'http://example.org', url: 'http://example.org/foo' },
{ expected: 'https://example.org', url: 'https://example.org/foo' },
{ expected: 'ws://example.org', url: 'ws://example.org/foo' },
{ expected: 'wss://example.org', url: 'wss://example.org/foo' },
{ expected: 'null', url: 'gopher://gopher.quux.org/1/' },
{ expected: 'null', url: 'file:///tmp/mock/path' },
{ expected: 'null', url: 'npm://nodejs/rules' }
].forEach((test) => {
Expand Down

0 comments on commit 0d08d5a

Please sign in to comment.