Skip to content

Commit

Permalink
fix(params): removing '[' and ']' from URL encode exclude characters (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
HealGaren committed May 19, 2023
1 parent 21a5ad3 commit ec83976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/helpers/buildURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ function encode(val) {
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, '+').
replace(/%5B/gi, '[').
replace(/%5D/gi, ']');
replace(/%20/g, '+');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions test/specs/helpers/buildURL.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('helpers::buildURL', function () {
foo: {
bar: 'baz'
}
})).toEqual('/foo?foo[bar]=baz');
})).toEqual('/foo?foo%5Bbar%5D=baz');
});

it('should support date params', function () {
Expand All @@ -48,10 +48,10 @@ describe('helpers::buildURL', function () {
})).toEqual('/foo?date=' + date.toISOString());
});

it('should support array params', function () {
it('should support array params with encode', function () {
expect(buildURL('/foo', {
foo: ['bar', 'baz', null, undefined]
})).toEqual('/foo?foo[]=bar&foo[]=baz');
foo: ['bar', 'baz']
})).toEqual('/foo?foo%5B%5D=bar&foo%5B%5D=baz');
});

it('should support special char params', function () {
Expand Down

0 comments on commit ec83976

Please sign in to comment.