Skip to content

Commit 7168049

Browse files
AlekseyLeshkorodneyrehm
authored andcommitted
fix(buildQuery): support params without key
closes #243 #383
1 parent fa46615 commit 7168049

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/URI.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@
744744
var t = '';
745745
var unique, key, i, length;
746746
for (key in data) {
747-
if (hasOwn.call(data, key) && key) {
747+
if (hasOwn.call(data, key)) {
748748
if (isArray(data[key])) {
749749
unique = {};
750750
for (i = 0, length = data[key].length; i < length; i++) {

test/test.js

+6
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,9 @@
13211321

13221322
u.query('?&foo=bar&foo=bar').normalizeQuery();
13231323
equal(u.query(), 'foo=bar', 'duplicate key=value resolution');
1324+
1325+
u.query('?=bar').normalizeQuery();
1326+
equal(u.query(), '=bar', 'query without key');
13241327
});
13251328
test('normalizeFragment', function() {
13261329
var u = new URI('http://example.org/foobar.html#');
@@ -1330,6 +1333,9 @@
13301333
test('readable', function() {
13311334
var u = new URI('http://foo:bar@www.xn--exmple-cua.org/hello%20world/ä.html?foo%5B%5D=b+är#fragment');
13321335
equal(u.readable(), 'http://www.exämple.org/hello world/ä.html?foo[]=b är#fragment', 'readable URL');
1336+
1337+
var u = new URI('http://example.org/?=5640');
1338+
equal(u.readable(), 'http://example.org/?=5640', 'readable URL: query without key');
13331339
});
13341340

13351341
module('resolving URLs');

0 commit comments

Comments
 (0)