url: ensure search property is consistently null vs empty

PR-URL: https://github.com/nodejs/node/pull/13606
Fixes: https://github.com/nodejs/node/issues/13404
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Justin Beckwith 2017-06-10 21:25:45 -07:00 committed by James M Snell
parent add4b0ab8c
commit c88ba036b4
2 changed files with 4 additions and 4 deletions

View File

@ -196,7 +196,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
this.query = this.search.slice(1);
}
} else if (parseQueryString) {
this.search = '';
this.search = null;
this.query = Object.create(null);
}
return this;
@ -389,7 +389,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
}
} else if (parseQueryString) {
// no query string, but parseQueryString still requested
this.search = '';
this.search = null;
this.query = Object.create(null);
}

View File

@ -36,7 +36,7 @@ const parseTestsWithQueryString = {
host: 'example.com',
hostname: 'example.com',
query: createWithNoPrototype(),
search: '',
search: null,
pathname: '/',
path: '/'
},
@ -48,7 +48,7 @@ const parseTestsWithQueryString = {
port: null,
hostname: null,
hash: null,
search: '',
search: null,
query: createWithNoPrototype(),
pathname: '/example',
path: '/example',