Use URLSearchParams for application/x-www-form-urlencoded

This commit is contained in:
Frank Jogeleit
2022-11-01 10:01:33 +01:00
parent fd5cf60c69
commit 50750c1420
4 changed files with 27 additions and 3 deletions

12
dist/index.js vendored
View File

@@ -2222,10 +2222,15 @@ module.exports.default = axios;
const axios = __webpack_require__(53);
const FormData = __webpack_require__(928)
const fs = __webpack_require__(747)
const url = __webpack_require__(835);
const METHOD_GET = 'GET'
const METHOD_POST = 'POST'
const HEADER_CONTENT_TYPE = 'Content-Type'
const CONTENT_TYPE_URLENCODED = 'application/x-www-form-urlencoded'
/**
* @param {Object} param0
* @param {string} param0.method HTTP Method
@@ -2273,6 +2278,13 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
updateConfigForFile(instanceConfig, file, actions)
}
if (instanceConfig.headers[HEADER_CONTENT_TYPE] === CONTENT_TYPE_URLENCODED) {
let dataJson = convertToJSON(data)
if (typeof dataJson === 'object') {
data = (new url.URLSearchParams(dataJson)).toString();
}
}
const requestData = {
method,
data,