summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGabriel Wicke <wicke@wikidev.net>2014-09-25 09:59:18 -0700
committerTrevor Norris <trev.norris@gmail.com>2014-10-01 12:23:01 -0700
commitb705b73e46193c7691be40b732330a49affacedb (patch)
tree9c02144948715fcb0b38ab379cea386d3438d609 /lib
parentac2857b12cd819b68405b15c3f8e95e48bcc32d8 (diff)
downloadnode-b705b73e46193c7691be40b732330a49affacedb.tar.gz
url: make query() consistent
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. Fixes: https://github.com/joyent/node/issues/8332 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/url.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/url.js b/lib/url.js
index 4c0ef0102..646342420 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -136,6 +136,9 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
} else {
this.query = this.search.substr(1);
}
+ } else if (parseQueryString) {
+ this.search = '';
+ this.query = {};
}
return this;
}