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

Added the ability for the url-encoded-form serializer to respect the formSerializer config; (#4721)

Added test for `formSerializer` config in context of `url-encoded-form` serializer;
This commit is contained in:
Dmitriy Mozgovoy
2022-05-17 09:26:35 +03:00
committed by GitHub
parent e6f9026d51
commit bd391247b4
4 changed files with 41 additions and 9 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ var defaults = {
if (isObjectPayload) {
if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
return toURLEncodedForm(data).toString();
return toURLEncodedForm(data, this.formSerializer).toString();
}
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') !== -1) {
+3 -3
View File
@@ -4,8 +4,8 @@ var utils = require('../utils');
var toFormData = require('./toFormData');
var platform = require('../platform/');
module.exports = function toURLEncodedForm(data) {
return toFormData(data, new platform.classes.URLSearchParams(), {
module.exports = function toURLEncodedForm(data, options) {
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
visitor: function(value, key, path, helpers) {
if (platform.isNode && utils.isBuffer(value)) {
this.append(key, value.toString('base64'));
@@ -14,5 +14,5 @@ module.exports = function toURLEncodedForm(data) {
return helpers.defaultVisitor.apply(this, arguments);
}
});
}, options));
};
@@ -1,8 +1,6 @@
'use strict';
module.exports = (function getURLSearchParams(nativeURLSearchParams) {
if (typeof nativeURLSearchParams === 'function') return nativeURLSearchParams;
module.exports = typeof URLSearchParams !== 'undefined' ? URLSearchParams : (function defineURLSearchParams() {
function encode(str) {
var charMap = {
'!': '%21',
@@ -35,4 +33,4 @@ module.exports = (function getURLSearchParams(nativeURLSearchParams) {
};
return URLSearchParams;
})(URLSearchParams);
})();