Browse Source

querystring: remove prepended ? from query field

Fixes an issue that caused the first querystring to be parsed prepending
a "?" in the first variable name on relative urls with no #fragment

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
v0.11.14-release
Ezequiel Rabinovich 11 years ago
committed by Trevor Norris
parent
commit
678ead2608
  1. 2
      lib/url.js
  2. 14
      test/simple/test-url.js

2
lib/url.js

@ -132,7 +132,7 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
if (simplePath[2]) {
this.search = simplePath[2];
if (parseQueryString) {
this.query = querystring.parse(this.search);
this.query = querystring.parse(this.search.substr(1));
} else {
this.query = this.search.substr(1);
}

14
test/simple/test-url.js

@ -867,6 +867,20 @@ var parseTestsWithQueryString = {
'search': '',
'pathname': '/',
'path': '/'
},
'/example?query=value':{
protocol: null,
slashes: null,
auth: null,
host: null,
port: null,
hostname: null,
hash: null,
search: '?query=value',
query: { query: 'value' },
pathname: '/example',
path: '/example?query=value',
href: '/example?query=value'
}
};
for (var u in parseTestsWithQueryString) {

Loading…
Cancel
Save