GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: discuss special protocol handling · nodejs/node@1b41cd4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • url.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/url.md‎

Copy file name to clipboardExpand all lines: doc/api/url.md
+40Lines changed: 40 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,46 @@ console.log(myURL.href);
389389

390390
Invalid URL protocol values assigned to the `protocol` property are ignored.
391391

392+
##### Special Schemes
393+
394+
The [WHATWG URL Standard][] considers a handful of URL protocol schemes to be
395+
_special_ in terms of how they are parsed and serialized. When a URL is
396+
parsed using one of these special protocols, the `url.protocol` property
397+
may be changed to another special protocol but cannot be changed to a
398+
non-special protocol, and vice versa.
399+
400+
For instance, changing from `http` to `https` works:
401+
402+
```js
403+
const u = new URL('http://example.org');
404+
u.protocol = 'https';
405+
console.log(u.href);
406+
// https://example.org
407+
```
408+
409+
However, changing from `http` to a hypothetical `fish` protocol does not
410+
because the new protocol is not special.
411+
412+
```js
413+
const u = new URL('http://example.org');
414+
u.protocol = 'fish';
415+
console.log(u.href);
416+
// http://example.org
417+
```
418+
419+
Likewise, changing from a non-special protocol to a special protocol is also
420+
not permitted:
421+
422+
```js
423+
const u = new URL('fish://example.org');
424+
u.protocol = 'http';
425+
console.log(u.href);
426+
// fish://example.org
427+
```
428+
429+
The protocol schemes considered to be special by the WHATWG URL Standard
430+
include: `ftp`, `file`, `gopher`, `http`, `https`, `ws`, and `wss`.
431+
392432
#### url.search
393433

394434
* {string}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.