Skip to content

Commit

Permalink
fixing addQuery() to work with null value - closes #171
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneyrehm committed Oct 1, 2014
1 parent dfa34f4 commit 06bf426
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ URI.js is published under the [MIT license](http://www.opensource.org/licenses/m

* fixing handling of String instances (not string primitives) - ([Issue #146](https://github.com/medialize/URI.js/issues/146))
* fixing Firefox [`.watch()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch) interfering with `.parseQuery()` - ([Issue #169](https://github.com/medialize/URI.js/issues/169))
* fixing [`addQuery()`](http://medialize.github.io/URI.js/docs.html#search-add) to not throw error on null value - ([Issue #171](https://github.com/medialize/URI.js/issues/171))

### 1.14.0 (September 8th 2014) ###

Expand Down
2 changes: 1 addition & 1 deletion src/URI.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@
value = [value];
}

data[name] = data[name].concat(value);
data[name] = (data[name] || []).concat(value);
} else {
throw new TypeError('URI.addQuery() accepts an object, string as the name parameter');
}
Expand Down
4 changes: 4 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,10 @@
u.addQuery('empty', '');
equal(u.query(), 'foo=bar&empty=', 'add empty string');

u.query('?foo');
u.addQuery('foo', 'bar');
equal(u.query(), 'foo=bar', 'add to null value');

u.query('');
u.addQuery('some value', 'must be encoded because of = and ? and #');
equal(u.query(), 'some+value=must+be+encoded+because+of+%3D+and+%3F+and+%23', 'encoding');
Expand Down

0 comments on commit 06bf426

Please sign in to comment.