Skip to content

Commit

Permalink
Fix DevTools request (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
adri9valle authored and Jesús Ángel committed Jun 3, 2019
1 parent 1ec7a64 commit 62350f2
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,18 @@ define([
} else {
method = 'GET'
}
const requestCopy = desiredGroup.requestText.includes(method)
let requestCopy = desiredGroup.requestText.includes(method)
? desiredGroup.requestText.split(method)[1].trim()
: desiredGroup.requestText

// Checks for inline parameters
let paramsInline = false
if (requestCopy.includes('{') && requestCopy.includes('}')) {
paramsInline = `{${requestCopy.split('{')[1]}`
requestCopy = requestCopy.split('{')[0]
}
const inlineSplit = requestCopy.split('?')

const extra =
inlineSplit && inlineSplit[1]
? queryString.parse(inlineSplit[1])
Expand All @@ -595,7 +602,7 @@ define([

let JSONraw = {}
try {
JSONraw = JSON.parse(desiredGroup.requestTextJson)
JSONraw = JSON.parse(paramsInline || desiredGroup.requestTextJson)
} catch (error) {
JSONraw = {}
}
Expand All @@ -604,17 +611,25 @@ define([
if (typeof JSONraw.pretty !== 'undefined') delete JSONraw.pretty

let path = ''
if (method === 'GET' || method === 'POST') {
if (method === 'PUT' || method === 'POST') {
// Assign inline parameters
for (const key in extra) JSONraw[key] = extra[key]
path = req.includes('?') ? req.split('?')[0] : req
} else {
if (extra) {
Object.keys(JSONraw).map(k => {
if (extra[k]) {
delete JSONraw[k]
}
})
}
path =
typeof JSONraw === 'object' && Object.keys(JSONraw).length
? `${req}${req.includes('?') ? '&' : '?'}${queryString.unescape(queryString.stringify(JSONraw))}`
: req;
: req
JSONraw = {}
}

//if (typeof JSONraw === 'object') JSONraw.devTools = true
if (!firstTime) {
const output = await this.request.apiReq(path, JSONraw, method)
Expand Down

0 comments on commit 62350f2

Please sign in to comment.