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: clarify that new URL().port could be an empty string. by mcollina · Pull Request #22232 · nodejs/node

doc: clarify that new URL().port could be an empty string. #22232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mcollina wants to merge 1 commit into nodejs:master from mcollina:url-doc-change

Uh oh!

There was an error while loading. Please reload this page.

Closed

doc: clarify that new URL().port could be an empty string. #22232

Changes from all commits
Commits
Show all changes
1 commit
Select commit
d5c6eb2
doc: clarify that new URL().port could be an empty string.
mcollina Aug 10, 2018
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

38 changes: 25 additions & 13 deletions 38 doc/api/url.md
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,31 @@ to percent-encode may vary somewhat from what the [`url.parse()`][] and

Gets and sets the port portion of the URL.

The port value may be a number or a string containing a number in the range
Comment thread

@BridgeAR BridgeAR Aug 14, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove containing a number

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Aug 17, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BridgeAR I disagree, I don't think it's clear enough without that. A string cannot be in a range of numbers.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@BridgeAR BridgeAR Aug 17, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are probably right.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
`0` to `65535` (inclusive). Setting the value to the default port of the
`URL` objects given `protocol` will result in the `port` value becoming
the empty string (`''`).

The port value can be an empty string in which case the port depends on
the protocol/scheme:

| protocol | port |
| :------- | :--- |
| "ftp" | 21 |
| "file" | |
| "gopher" | 70 |
| "http" | 80 |
| "https" | 443 |
| "ws" | 80 |
| "wss" | 443 |

Upon assigning a value to the port, the value will first be converted to a
string using `.toString()`.

If that string is invalid but it begins with a number, the leading number is
assigned to `port`.
If the number lies outside the range denoted above, it is ignored.

```js
const myURL = new URL('https://example.org:8888');
console.log(myURL.port);
Expand Down Expand Up @@ -346,19 +371,6 @@ console.log(myURL.port);
// Prints 1234
```

The port value may be set as either a number or as a string containing a number
in the range `0` to `65535` (inclusive). Setting the value to the default port
of the `URL` objects given `protocol` will result in the `port` value becoming
the empty string (`''`).

Upon assigning a value to the port, the value will first be converted to a
string using `.toString()`.

If that string is invalid but it begins with a number, the leading number is
assigned to `port`.
Otherwise, or if the number lies outside the range denoted above,
it is ignored.

Note that numbers which contain a decimal point,
such as floating-point numbers or numbers in scientific notation,
are not an exception to this rule.
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.