Skip to content
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

docs: state decoding behavior for url pathname #1731

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions doc/api/url.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ string will not be in the parsed object. Examples are shown for the URL
Example: `'8080'`

* `pathname`: The path section of the URL, that comes after the host and
before the query, including the initial slash if present.
before the query, including the initial slash if present. No decoding is
performed.

Example: `'/p/a/t/h'`

Expand All @@ -50,7 +51,7 @@ string will not be in the parsed object. Examples are shown for the URL

Example: `'?query=string'`

* `path`: Concatenation of `pathname` and `search`.
* `path`: Concatenation of `pathname` and `search`. No decoding is performed.

Example: `'/p/a/t/h?query=string'`

Expand All @@ -72,7 +73,8 @@ Take a URL string, and return an object.
Pass `true` as the second argument to also parse the query string using the
`querystring` module. If `true` then the `query` property will always be
assigned an object, and the `search` property will always be a (possibly
empty) string. Defaults to `false`.
empty) string. If `false` then the neither the `query` nor the `search`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the superfluous 'the ' before 'neither'.

properties will be parsed or decoded. Defaults to `false`.
Copy link
Contributor

Choose a reason for hiding this comment

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

By looking at the code I'm not really sure search is parsed at all?

Not too familiar with url code though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good find, it looks like only query is decoded:

> url.parse('http://foo.com/?%26', true).search
'?%26'
> url.parse('http://foo.com/?%26', true).query
{ '&': '' }

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, query is the decoded from the search field.


Pass `true` as the third argument to treat `//foo/bar` as
`{ host: 'foo', pathname: '/bar' }` rather than
Expand Down