diff --git a/lib/url.js b/lib/url.js index 6227c8a057a4ce..8a76d1fc10aef5 100644 --- a/lib/url.js +++ b/lib/url.js @@ -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); } diff --git a/test/parallel/test-url-parse-query.js b/test/parallel/test-url-parse-query.js index 34c31d8a3ca229..67682d0aad7fa5 100644 --- a/test/parallel/test-url-parse-query.js +++ b/test/parallel/test-url-parse-query.js @@ -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',