Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Make url.query consistent between slow & fast path #8451

Closed
wants to merge 1 commit into from

Conversation

gwicke
Copy link

@gwicke gwicke commented Sep 25, 2014

Match the behavior of the slow path by setting url.query to an empty object
when the url contains no query, but query parsing is requested.

Also add a test for this case.

issue: #8332

@chrisdickinson
Copy link

Great work! Would you mind updating the URL docs to reflect that the query object will always be present if parseQueryString is true?

@@ -136,6 +136,10 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
} else {
this.query = this.search.substr(1);
}
} else if (parseQueryString) {
// https://github.com/joyent/node/issues/8332

Choose a reason for hiding this comment

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

Please remove the link. Any needed information about why this code was introduced can be viewed via git blame and looking at the commit log.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@trevnorris
Copy link

@gwicke Here's an example diff for the doc change:

diff --git a/doc/api/url.markdown b/doc/api/url.markdown
index e6a43f7..679f6f1 100644
--- a/doc/api/url.markdown
+++ b/doc/api/url.markdown
@@ -69,8 +69,9 @@ The following methods are provided by the URL module:

 Take a URL string, and return an object.

-Pass `true` as the second argument to also parse
-the query string using the `querystring` module.
+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.
 Defaults to `false`.

 Pass `true` as the third argument to treat `//foo/bar` as

Do that and we'll throw this on.

Match the behavior of the slow path by setting url.query to an empty object
when the url contains no query, but query parsing is requested.

Also add a test for this case, and update the documents to clearly reflect
this behavior.

issue: nodejs#8332
@gwicke
Copy link
Author

gwicke commented Oct 1, 2014

Also mentioned the search property in the doc patch.

@trevnorris
Copy link

Thanks. Merged in b705b73.

@trevnorris trevnorris closed this Oct 1, 2014
@gwicke gwicke deleted the issue_8332 branch October 2, 2014 01:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants