From c88ba036b46e56f11d56c4679adbd9ff66bce645 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/13606 Fixes: https://github.com/nodejs/node/issues/13404 Reviewed-By: Timothy Gu Reviewed-By: Luigi Pinca Reviewed-By: Yuta Hiroto Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Matteo Collina Reviewed-By: Daijiro Wachi Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- 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',