🐛 Fixed broken cURL import. Fix #477
This commit is contained in:
@@ -23,7 +23,7 @@ const parseCurlCommand = curlCommand => {
|
|||||||
let newlineFound = /\r|\n/.exec(curlCommand);
|
let newlineFound = /\r|\n/.exec(curlCommand);
|
||||||
if (newlineFound) {
|
if (newlineFound) {
|
||||||
// remove newlines
|
// remove newlines
|
||||||
curlCommand = curlCommand.replace(/\\\r|\\\n/g, "");
|
curlCommand = curlCommand.replace(/\r|\n/g, "");
|
||||||
}
|
}
|
||||||
// yargs parses -XPOST as separate arguments. just prescreen for it.
|
// yargs parses -XPOST as separate arguments. just prescreen for it.
|
||||||
curlCommand = curlCommand.replace(/ -XPOST/, " -X POST");
|
curlCommand = curlCommand.replace(/ -XPOST/, " -X POST");
|
||||||
|
|||||||
@@ -1461,26 +1461,26 @@ export default {
|
|||||||
return requestString.join("");
|
return requestString.join("");
|
||||||
} else if (this.requestType === "cURL") {
|
} else if (this.requestType === "cURL") {
|
||||||
const requestString = [];
|
const requestString = [];
|
||||||
requestString.push("curl -X " + this.method + " \\\n");
|
requestString.push("curl -X " + this.method + " \n");
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" '" + this.url + this.pathName + this.queryString + "' \\\n"
|
" '" + this.url + this.pathName + this.queryString + "' \n"
|
||||||
);
|
);
|
||||||
if (this.auth === "Basic Auth") {
|
if (this.auth === "Basic Auth") {
|
||||||
const basic = this.httpUser + ":" + this.httpPassword;
|
const basic = this.httpUser + ":" + this.httpPassword;
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" -H 'Authorization: Basic " +
|
" -H 'Authorization: Basic " +
|
||||||
window.btoa(unescape(encodeURIComponent(basic))) +
|
window.btoa(unescape(encodeURIComponent(basic))) +
|
||||||
"' \\\n"
|
"' \n"
|
||||||
);
|
);
|
||||||
} else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
|
} else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" -H 'Authorization: Bearer " + this.bearerToken + "' \\\n"
|
" -H 'Authorization: Bearer " + this.bearerToken + "' \n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (this.headers) {
|
if (this.headers) {
|
||||||
this.headers.forEach(element => {
|
this.headers.forEach(element => {
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" -H '" + element.key + ": " + element.value + "' \\\n"
|
" -H '" + element.key + ": " + element.value + "' \n"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1489,14 +1489,14 @@ export default {
|
|||||||
? this.rawParams
|
? this.rawParams
|
||||||
: this.rawRequestBody;
|
: this.rawRequestBody;
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" -H 'Content-Length: " + requestBody.length + "' \\\n"
|
" -H 'Content-Length: " + requestBody.length + "' \n"
|
||||||
);
|
);
|
||||||
requestString.push(
|
requestString.push(
|
||||||
" -H 'Content-Type: " + this.contentType + "; charset=utf-8' \\\n"
|
" -H 'Content-Type: " + this.contentType + "; charset=utf-8' \n"
|
||||||
);
|
);
|
||||||
requestString.push(" -d '" + requestBody + "' \\\n");
|
requestString.push(" -d '" + requestBody + "' \n");
|
||||||
}
|
}
|
||||||
return requestString.join("").slice(0, -3);
|
return requestString.join("").slice(0, -2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2015,11 +2015,13 @@ export default {
|
|||||||
this.url = url.origin;
|
this.url = url.origin;
|
||||||
this.path = url.pathname;
|
this.path = url.pathname;
|
||||||
this.headers = [];
|
this.headers = [];
|
||||||
for (const key of Object.keys(parsedCurl.headers)) {
|
if (parsedCurl.headers) {
|
||||||
this.$store.commit("addHeaders", {
|
for (const key of Object.keys(parsedCurl.headers)) {
|
||||||
key: key,
|
this.$store.commit("addHeaders", {
|
||||||
value: parsedCurl.headers[key]
|
key: key,
|
||||||
});
|
value: parsedCurl.headers[key]
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.method = parsedCurl.method.toUpperCase();
|
this.method = parsedCurl.method.toUpperCase();
|
||||||
if (parsedCurl["data"]) {
|
if (parsedCurl["data"]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user