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:
parent
add4b0ab8c
commit
c88ba036b4
@ -196,7 +196,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
this.query = this.search.slice(1);
|
this.query = this.search.slice(1);
|
||||||
}
|
}
|
||||||
} else if (parseQueryString) {
|
} else if (parseQueryString) {
|
||||||
this.search = '';
|
this.search = null;
|
||||||
this.query = Object.create(null);
|
this.query = Object.create(null);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -389,7 +389,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
}
|
}
|
||||||
} else if (parseQueryString) {
|
} else if (parseQueryString) {
|
||||||
// no query string, but parseQueryString still requested
|
// no query string, but parseQueryString still requested
|
||||||
this.search = '';
|
this.search = null;
|
||||||
this.query = Object.create(null);
|
this.query = Object.create(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const parseTestsWithQueryString = {
|
|||||||
host: 'example.com',
|
host: 'example.com',
|
||||||
hostname: 'example.com',
|
hostname: 'example.com',
|
||||||
query: createWithNoPrototype(),
|
query: createWithNoPrototype(),
|
||||||
search: '',
|
search: null,
|
||||||
pathname: '/',
|
pathname: '/',
|
||||||
path: '/'
|
path: '/'
|
||||||
},
|
},
|
||||||
@ -48,7 +48,7 @@ const parseTestsWithQueryString = {
|
|||||||
port: null,
|
port: null,
|
||||||
hostname: null,
|
hostname: null,
|
||||||
hash: null,
|
hash: null,
|
||||||
search: '',
|
search: null,
|
||||||
query: createWithNoPrototype(),
|
query: createWithNoPrototype(),
|
||||||
pathname: '/example',
|
pathname: '/example',
|
||||||
path: '/example',
|
path: '/example',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user