mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-11-22 03:41:00 -05:00
Merge pull request #62 from fjogeleit/url-encoded
Use URLSearchParams for application/x-www-form-urlencoded
This commit is contained in:
commit
79a8b8af48
4 changed files with 27 additions and 3 deletions
12
dist/index.js
vendored
12
dist/index.js
vendored
|
@ -2672,10 +2672,15 @@ module.exports.default = axios;
|
||||||
const axios = __webpack_require__(53);
|
const axios = __webpack_require__(53);
|
||||||
const FormData = __webpack_require__(928)
|
const FormData = __webpack_require__(928)
|
||||||
const fs = __webpack_require__(747)
|
const fs = __webpack_require__(747)
|
||||||
|
const url = __webpack_require__(835);
|
||||||
|
|
||||||
const METHOD_GET = 'GET'
|
const METHOD_GET = 'GET'
|
||||||
const METHOD_POST = 'POST'
|
const METHOD_POST = 'POST'
|
||||||
|
|
||||||
|
const HEADER_CONTENT_TYPE = 'Content-Type'
|
||||||
|
|
||||||
|
const CONTENT_TYPE_URLENCODED = 'application/x-www-form-urlencoded'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} param0
|
* @param {Object} param0
|
||||||
* @param {string} param0.method HTTP Method
|
* @param {string} param0.method HTTP Method
|
||||||
|
@ -2723,6 +2728,13 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
|
||||||
updateConfigForFile(instanceConfig, file, actions)
|
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 = {
|
const requestData = {
|
||||||
method,
|
method,
|
||||||
data,
|
data,
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "http-request-action",
|
"name": "http-request-action",
|
||||||
"version": "1.9.0",
|
"version": "1.11.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "http-request-action",
|
"name": "http-request-action",
|
||||||
"version": "1.9.0",
|
"version": "1.11.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.9.1"
|
"@actions/core": "^1.9.1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "http-request-action",
|
"name": "http-request-action",
|
||||||
"version": "1.9.0",
|
"version": "1.11.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"private": false,
|
"private": false,
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const FormData = require('form-data')
|
const FormData = require('form-data')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
const METHOD_GET = 'GET'
|
const METHOD_GET = 'GET'
|
||||||
const METHOD_POST = 'POST'
|
const METHOD_POST = 'POST'
|
||||||
|
|
||||||
|
const HEADER_CONTENT_TYPE = 'Content-Type'
|
||||||
|
|
||||||
|
const CONTENT_TYPE_URLENCODED = 'application/x-www-form-urlencoded'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} param0
|
* @param {Object} param0
|
||||||
* @param {string} param0.method HTTP Method
|
* @param {string} param0.method HTTP Method
|
||||||
|
@ -52,6 +57,13 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
|
||||||
updateConfigForFile(instanceConfig, file, actions)
|
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 = {
|
const requestData = {
|
||||||
method,
|
method,
|
||||||
data,
|
data,
|
||||||
|
|
Loading…
Reference in a new issue