Skip to content

Commit

Permalink
fix(buildQuery): support params without key
Browse files Browse the repository at this point in the history
closes #243 #383
  • Loading branch information
AlekseyLeshko authored and rodneyrehm committed Oct 20, 2019
1 parent fa46615 commit 7168049
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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#');
Expand All @@ -1330,6 +1333,9 @@
test('readable', function() {
var u = new URI('http://foo:[email protected]/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://example.org/?=5640');
equal(u.readable(), 'http://example.org/?=5640', 'readable URL: query without key');
});

module('resolving URLs');
Expand Down

0 comments on commit 7168049

Please sign in to comment.