-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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.
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
doc: add url.resolve() method's behaviour #8991
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,11 +230,28 @@ manner similar to that of a Web browser resolving an anchor tag HREF. | |
For example: | ||
|
||
```js | ||
url.resolve('/one/two/three', 'four') // '/one/two/four' | ||
url.resolve('http://example.com/', '/one') // 'http://example.com/one' | ||
url.resolve('http://example.com/one', '/two') // 'http://example.com/two' | ||
url.resolve('/one/two/three', 'four'); // '/one/two/four' | ||
url.resolve('http://example.com/', '/one'); // 'http://example.com/one' | ||
url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' | ||
``` | ||
|
||
Some protocols (`http`, `https`, `ftp`, `gopher` and `file`) are treated as special cases. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is special about them? The docs don't say. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has been explained explicitly with the help of examples how the usual behaviour might differ taking into the consideration the different protocols |
||
Every other (for instance ftps or wss) is treated differently whether its URL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is different? The docs don't say. |
||
ends in a slash or not. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest wording this a bit differently:
|
||
|
||
For example: | ||
|
||
```js | ||
url.resolve('https://foo.tld', 'bar'); // 'https://foo.tld/bar' | ||
url.resolve('wss://foo.tld', 'bar'); // 'wss://bar' | ||
url.resolve('ftps://foo.tld', 'bar'); // 'ftps://bar' | ||
``` | ||
|
||
Although, the uniform behaviour of the method is achieved when the URL ends with a slash. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the uniform behaviour? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #8057 Please go through the issue that has been addressed here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, that isn't helpful - the point of the docs is to explain, and they aren't, so having me go read a node issue to understand a doc change is a bit backwards. As is, this PR adds some extra examples and some lines of text that basically say "look carefully at the examples to see how this API works, paying particular attention to the protocol scheme, because it changes the behaviour". This is arguably an improvement over the existing doc, if @addaleax is happy with that, I've no objection. However, it still doesn't document the API behaviour. If you have the interest, the existing docs could be improved even more. If not, I understand. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, that’s what my approval of this PR is based upon. I don’t disagree with you that this still leaves room for improvement. |
||
|
||
```js | ||
url.resolve("ftps://foo.tld/", "bar"); // 'ftps://foo.tld/bar' | ||
``` | ||
## Escaped Characters | ||
|
||
URLs are only permitted to contain a certain range of characters. Spaces (`' '`) | ||
|
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.
Can you add a line break at column <= 80? This applies for all lines not only this one.
Thanks!