Fixed #1159
This commit is contained in:
parent
41127da7d9
commit
005db4d0e8
2 changed files with 6 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import * as cookie from "cookie"
|
||||
import * as URL from "url"
|
||||
import * as querystring from "querystring"
|
||||
import parser from "yargs-parser"
|
||||
|
||||
/**
|
||||
* given this: [ 'msg1=value1', 'msg2=value2' ]
|
||||
|
|
@ -20,10 +21,10 @@ const joinDataArguments = (dataArguments) => {
|
|||
}
|
||||
|
||||
const parseCurlCommand = (curlCommand) => {
|
||||
let newlineFound = /\r|\n/.exec(curlCommand)
|
||||
let newlineFound = /\r?\n|\r/.exec(curlCommand)
|
||||
if (newlineFound) {
|
||||
// remove newlines
|
||||
curlCommand = curlCommand.replace(/\r|\n/g, "")
|
||||
curlCommand = curlCommand.replace(/\r?\n|\r/g, "")
|
||||
}
|
||||
// yargs parses -XPOST as separate arguments. just prescreen for it.
|
||||
curlCommand = curlCommand.replace(/ -XPOST/, " -X POST")
|
||||
|
|
@ -32,10 +33,10 @@ const parseCurlCommand = (curlCommand) => {
|
|||
curlCommand = curlCommand.replace(/ -XPATCH/, " -X PATCH")
|
||||
curlCommand = curlCommand.replace(/ -XDELETE/, " -X DELETE")
|
||||
curlCommand = curlCommand.trim()
|
||||
let parsedArguments = require("yargs-parser")(curlCommand)
|
||||
let parsedArguments = parser(curlCommand)
|
||||
let cookieString
|
||||
let cookies
|
||||
let url = parsedArguments._[1]
|
||||
let url = parsedArguments._[2]
|
||||
if (!url) {
|
||||
for (let argName in parsedArguments) {
|
||||
if (typeof parsedArguments[argName] === "string") {
|
||||
|
|
|
|||
|
|
@ -2413,6 +2413,7 @@ export default {
|
|||
const { origin, pathname } = new URL(parsedCurl.url.replace(/"/g, "").replace(/'/g, ""))
|
||||
this.url = origin
|
||||
this.path = pathname
|
||||
this.uri = this.url + this.path
|
||||
this.headers = []
|
||||
if (parsedCurl.headers) {
|
||||
for (const key of Object.keys(parsedCurl.headers)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue