Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added string cast for non-string value being compared when removing query parameter. #252

Merged
merged 1 commit into from
Sep 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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