2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

URL params serializer; (#4734)

* Refactored BuildURL helper to use URLSearchParams serializer;

* Updated typings;
Added TS test;
This commit is contained in:
Dmitriy Mozgovoy
2022-05-25 09:16:38 +03:00
committed by GitHub
parent 467025bdb7
commit 934f390cc3
7 changed files with 84 additions and 87 deletions
+1 -10
View File
@@ -17,7 +17,7 @@ describe('helpers::buildURL', function () {
foo: {
bar: 'baz'
}
})).toEqual('/foo?foo=' + encodeURI('{"bar":"baz"}'));
})).toEqual('/foo?foo[bar]=baz');
});
it('should support date params', function () {
@@ -60,15 +60,6 @@ describe('helpers::buildURL', function () {
})).toEqual('/foo?foo=bar&query=baz');
});
it('should use serializer if provided', function () {
serializer = sinon.stub();
params = {foo: 'bar'};
serializer.returns('foo=bar');
expect(buildURL('/foo', params, serializer)).toEqual('/foo?foo=bar');
expect(serializer.calledOnce).toBe(true);
expect(serializer.calledWith(params)).toBe(true);
});
it('should support URLSearchParams', function () {
expect(buildURL('/foo', new URLSearchParams('bar=baz'))).toEqual('/foo?bar=baz');
});