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 <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>
  • 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.