Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt DevTools #731

Merged
merged 3 commits into from
Jun 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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