mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
feat: added custom params serializer support; (#5113)
* Added custom params serializer support; * Added missed semicolon; Fixed allowUnknown option; Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+13
-5
@@ -44,12 +44,20 @@ export default function buildURL(url, params, options) {
|
||||
|
||||
const _encode = options && options.encode || encode;
|
||||
|
||||
const serializerParams = utils.isURLSearchParams(params) ?
|
||||
params.toString() :
|
||||
new AxiosURLSearchParams(params, options).toString(_encode);
|
||||
const serializeFn = options && options.serialize;
|
||||
|
||||
if (serializerParams) {
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializerParams;
|
||||
let serializedParams;
|
||||
|
||||
if (serializeFn) {
|
||||
serializedParams = serializeFn(params, options);
|
||||
} else {
|
||||
serializedParams = utils.isURLSearchParams(params) ?
|
||||
params.toString() :
|
||||
new AxiosURLSearchParams(params, options).toString(_encode);
|
||||
}
|
||||
|
||||
if (serializedParams) {
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
||||
}
|
||||
|
||||
return url;
|
||||
|
||||
Reference in New Issue
Block a user