Skip to content

Commit c88ba03

Browse files
JustinBeckwithjasnell
authored andcommitted
url: ensure search property is consistently null vs empty
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]>
1 parent add4b0a commit c88ba03

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/url.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
196196
this.query = this.search.slice(1);
197197
}
198198
} else if (parseQueryString) {
199-
this.search = '';
199+
this.search = null;
200200
this.query = Object.create(null);
201201
}
202202
return this;
@@ -389,7 +389,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
389389
}
390390
} else if (parseQueryString) {
391391
// no query string, but parseQueryString still requested
392-
this.search = '';
392+
this.search = null;
393393
this.query = Object.create(null);
394394
}
395395

test/parallel/test-url-parse-query.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const parseTestsWithQueryString = {
3636
host: 'example.com',
3737
hostname: 'example.com',
3838
query: createWithNoPrototype(),
39-
search: '',
39+
search: null,
4040
pathname: '/',
4141
path: '/'
4242
},
@@ -48,7 +48,7 @@ const parseTestsWithQueryString = {
4848
port: null,
4949
hostname: null,
5050
hash: null,
51-
search: '',
51+
search: null,
5252
query: createWithNoPrototype(),
5353
pathname: '/example',
5454
path: '/example',

0 commit comments

Comments
 (0)