Skip to content

Commit

Permalink
url: ensure search property is consistently null vs empty
Browse files Browse the repository at this point in the history
PR-URL: #13606
Fixes: #13404
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
JustinBeckwith authored and jasnell committed Jun 13, 2017
1 parent add4b0a commit c88ba03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-url-parse-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const parseTestsWithQueryString = {
host: 'example.com',
hostname: 'example.com',
query: createWithNoPrototype(),
search: '',
search: null,
pathname: '/',
path: '/'
},
Expand All @@ -48,7 +48,7 @@ const parseTestsWithQueryString = {
port: null,
hostname: null,
hash: null,
search: '',
search: null,
query: createWithNoPrototype(),
pathname: '/example',
path: '/example',
Expand Down

0 comments on commit c88ba03

Please sign in to comment.