Skip to content

Commit

Permalink
Merge pull request #252 from ryanelian/stringcast
Browse files Browse the repository at this point in the history
fix(removeQuery): adding cast-to-string for values being removed from query string.
  • Loading branch information
rodneyrehm committed Sep 26, 2015
2 parents f406808 + 30197c0 commit 1b7fbce
Show file tree
Hide file tree
Showing 2 changed files with 8 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 @@ -777,7 +777,7 @@
} else {
data[name] = filterArrayValues(data[name], value);
}
} else if (data[name] === value) {
} else if (data[name] === String(value)) {
data[name] = undefined;
} else if (isArray(data[name])) {
data[name] = filterArrayValues(data[name], value);
Expand Down
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,13 @@
u.removeQuery(['foo', 'bar']);
equal(u.query(), 'obj=bam', 'removing array');

u.query('?bar=1&bar=2');
u.removeQuery({ bar: 1 });
equal(u.query(), 'bar=2', 'removing non-string value from array');

u.removeQuery({ bar: 2 });
equal(u.query(), '', 'removing a non-string value');

u.query('?foo=bar&foo=baz&foo=bam&obj=bam&bar=1&bar=2&bar=3');
u.removeQuery({foo: 'bar', obj: undefined, bar: ['1', '2']});
equal(u.query(), 'foo=baz&foo=bam&bar=3', 'removing object');
Expand Down

0 comments on commit 1b7fbce

Please sign in to comment.