From 1816653e29f2077c7696bcc0fdd52d99737dae73 Mon Sep 17 00:00:00 2001 From: AlekseyLeshko Date: Tue, 6 Aug 2019 23:49:47 +0300 Subject: [PATCH 1/3] Add support the query param without key --- src/URI.js | 2 +- test/test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/URI.js b/src/URI.js index cb52699e..8b0c24d6 100644 --- a/src/URI.js +++ b/src/URI.js @@ -744,7 +744,7 @@ var t = ''; var unique, key, i, length; for (key in data) { - if (hasOwn.call(data, key) && key) { + if (hasOwn.call(data, key)) { if (isArray(data[key])) { unique = {}; for (i = 0, length = data[key].length; i < length; i++) { diff --git a/test/test.js b/test/test.js index c29c2ad1..f9b44090 100644 --- a/test/test.js +++ b/test/test.js @@ -1321,6 +1321,9 @@ u.query('?&foo=bar&foo=bar').normalizeQuery(); equal(u.query(), 'foo=bar', 'duplicate key=value resolution'); + + u.query('?=bar').normalizeQuery(); + equal(u.query(), '=bar', 'query without key'); }); test('normalizeFragment', function() { var u = new URI('http://example.org/foobar.html#'); @@ -1330,6 +1333,9 @@ test('readable', function() { var u = new URI('http://foo:bar@www.xn--exmple-cua.org/hello%20world/ä.html?foo%5B%5D=b+är#fragment'); equal(u.readable(), 'http://www.exämple.org/hello world/ä.html?foo[]=b är#fragment', 'readable URL'); + + var u = new URI('http://hvgbook.net/?=5640'); + equal(u.readable(), 'http://hvgbook.net/?=5640', 'readable URL: query where no name'); }); module('resolving URLs'); From 94833c73313dc6a070bf4c3f7efc8eaadc21f3bf Mon Sep 17 00:00:00 2001 From: AlekseyLeshko Date: Tue, 6 Aug 2019 23:58:20 +0300 Subject: [PATCH 2/3] Fix --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index f9b44090..3946d10b 100644 --- a/test/test.js +++ b/test/test.js @@ -1335,7 +1335,7 @@ equal(u.readable(), 'http://www.exämple.org/hello world/ä.html?foo[]=b är#fragment', 'readable URL'); var u = new URI('http://hvgbook.net/?=5640'); - equal(u.readable(), 'http://hvgbook.net/?=5640', 'readable URL: query where no name'); + equal(u.readable(), 'http://hvgbook.net/?=5640', 'readable URL: query without key'); }); module('resolving URLs'); From 82948fc1b467c33d158b12630cd4e1f1047887b8 Mon Sep 17 00:00:00 2001 From: AlekseyLeshko Date: Sat, 21 Sep 2019 14:10:46 +0300 Subject: [PATCH 3/3] Change domain in test --- test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 3946d10b..716ec761 100644 --- a/test/test.js +++ b/test/test.js @@ -1334,8 +1334,8 @@ var u = new URI('http://foo:bar@www.xn--exmple-cua.org/hello%20world/ä.html?foo%5B%5D=b+är#fragment'); equal(u.readable(), 'http://www.exämple.org/hello world/ä.html?foo[]=b är#fragment', 'readable URL'); - var u = new URI('http://hvgbook.net/?=5640'); - equal(u.readable(), 'http://hvgbook.net/?=5640', 'readable URL: query without key'); + var u = new URI('http://example.org/?=5640'); + equal(u.readable(), 'http://example.org/?=5640', 'readable URL: query without key'); }); module('resolving URLs');