From d7256990877bbda9ed9a71814587bf3793b0188f Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Sat, 10 Jun 2017 21:25:45 -0700 Subject: [PATCH] url: ensure search property is consistently null vs empty Fixes: https://github.com/nodejs/node/issues/13404 --- lib/url.js | 4 ++-- test/parallel/test-url-parse-query.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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',