🐛 Fixed URI not recognizing query parameters
This commit is contained in:
@@ -186,6 +186,7 @@
|
|||||||
type="url"
|
type="url"
|
||||||
v-model="uri"
|
v-model="uri"
|
||||||
spellcheck="false"
|
spellcheck="false"
|
||||||
|
@input="pathInputHandler"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<div>
|
<div>
|
||||||
@@ -1341,13 +1342,13 @@ const statusCategories = [
|
|||||||
className: "missing-data-response",
|
className: "missing-data-response",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const parseHeaders = xhr => {
|
const parseHeaders = (xhr) => {
|
||||||
const headers = xhr
|
const headers = xhr
|
||||||
.getAllResponseHeaders()
|
.getAllResponseHeaders()
|
||||||
.trim()
|
.trim()
|
||||||
.split(/[\r\n]+/)
|
.split(/[\r\n]+/)
|
||||||
const headerMap = {}
|
const headerMap = {}
|
||||||
headers.forEach(line => {
|
headers.forEach((line) => {
|
||||||
const parts = line.split(": ")
|
const parts = line.split(": ")
|
||||||
const header = parts.shift().toLowerCase()
|
const header = parts.shift().toLowerCase()
|
||||||
const value = parts.join(": ")
|
const value = parts.join(": ")
|
||||||
@@ -1355,8 +1356,8 @@ const parseHeaders = xhr => {
|
|||||||
})
|
})
|
||||||
return headerMap
|
return headerMap
|
||||||
}
|
}
|
||||||
export const findStatusGroup = responseStatus =>
|
export const findStatusGroup = (responseStatus) =>
|
||||||
statusCategories.find(status => status.statusCodeRegex.test(responseStatus))
|
statusCategories.find((status) => status.statusCodeRegex.test(responseStatus))
|
||||||
export default {
|
export default {
|
||||||
directives: {
|
directives: {
|
||||||
textareaAutoHeight,
|
textareaAutoHeight,
|
||||||
@@ -1445,7 +1446,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
contentType(contentType, oldContentType) {
|
contentType(contentType, oldContentType) {
|
||||||
const getDefaultParams = contentType => {
|
const getDefaultParams = (contentType) => {
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
case "application/json":
|
case "application/json":
|
||||||
case "application/vnd.api+json":
|
case "application/vnd.api+json":
|
||||||
@@ -1463,7 +1464,7 @@ export default {
|
|||||||
}
|
}
|
||||||
this.setRouteQueryState()
|
this.setRouteQueryState()
|
||||||
},
|
},
|
||||||
"response.body": function(val) {
|
"response.body": function (val) {
|
||||||
if (
|
if (
|
||||||
this.response.body === this.$t("waiting_send_req") ||
|
this.response.body === this.$t("waiting_send_req") ||
|
||||||
this.response.body === this.$t("loading")
|
this.response.body === this.$t("loading")
|
||||||
@@ -1488,7 +1489,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
handler: function(newValue) {
|
handler: function (newValue) {
|
||||||
if (!this.paramsWatchEnabled) {
|
if (!this.paramsWatchEnabled) {
|
||||||
this.paramsWatchEnabled = true
|
this.paramsWatchEnabled = true
|
||||||
return
|
return
|
||||||
@@ -1566,7 +1567,7 @@ export default {
|
|||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setState", { value, attribute: "uri" })
|
this.$store.commit("setState", { value, attribute: "uri" })
|
||||||
let url
|
let url = value
|
||||||
if (this.preRequestScript && this.showPreRequestScript) {
|
if (this.preRequestScript && this.showPreRequestScript) {
|
||||||
const environmentVariables = getEnvironmentVariablesFromScript(this.preRequestScript)
|
const environmentVariables = getEnvironmentVariablesFromScript(this.preRequestScript)
|
||||||
url = parseTemplateString(value, environmentVariables)
|
url = parseTemplateString(value, environmentVariables)
|
||||||
@@ -2076,7 +2077,7 @@ export default {
|
|||||||
: null
|
: null
|
||||||
let headers = {}
|
let headers = {}
|
||||||
let headersObject = {}
|
let headersObject = {}
|
||||||
Object.keys(headers).forEach(id => {
|
Object.keys(headers).forEach((id) => {
|
||||||
headersObject[headers[id].key] = headers[id].value
|
headersObject[headers[id].key] = headers[id].value
|
||||||
})
|
})
|
||||||
headers = headersObject
|
headers = headersObject
|
||||||
@@ -2112,7 +2113,7 @@ export default {
|
|||||||
// specify them.
|
// specify them.
|
||||||
// headers
|
// headers
|
||||||
)
|
)
|
||||||
Object.keys(headers).forEach(id => {
|
Object.keys(headers).forEach((id) => {
|
||||||
headersObject[headers[id].key] = headers[id].value
|
headersObject[headers[id].key] = headers[id].value
|
||||||
})
|
})
|
||||||
headers = headersObject
|
headers = headersObject
|
||||||
@@ -2214,21 +2215,23 @@ export default {
|
|||||||
},
|
},
|
||||||
getQueryStringFromPath() {
|
getQueryStringFromPath() {
|
||||||
let queryString
|
let queryString
|
||||||
const pathParsed = url.parse(this.path)
|
const pathParsed = url.parse(this.uri)
|
||||||
return (queryString = pathParsed.query ? pathParsed.query : "")
|
return (queryString = pathParsed.query ? pathParsed.query : "")
|
||||||
},
|
},
|
||||||
queryStringToArray(queryString) {
|
queryStringToArray(queryString) {
|
||||||
const queryParsed = querystring.parse(queryString)
|
const queryParsed = querystring.parse(queryString)
|
||||||
return Object.keys(queryParsed).map(key => ({
|
return Object.keys(queryParsed).map((key) => ({
|
||||||
key,
|
key,
|
||||||
value: queryParsed[key],
|
value: queryParsed[key],
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
pathInputHandler() {
|
pathInputHandler() {
|
||||||
const queryString = this.getQueryStringFromPath()
|
if (this.uri.includes("?")) {
|
||||||
const params = this.queryStringToArray(queryString)
|
const queryString = this.getQueryStringFromPath()
|
||||||
this.paramsWatchEnabled = false
|
const params = this.queryStringToArray(queryString)
|
||||||
this.params = params
|
this.paramsWatchEnabled = false
|
||||||
|
this.params = params
|
||||||
|
}
|
||||||
},
|
},
|
||||||
addRequestHeader() {
|
addRequestHeader() {
|
||||||
this.$store.commit("addHeaders", {
|
this.$store.commit("addHeaders", {
|
||||||
@@ -2388,8 +2391,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setRouteQueryState() {
|
setRouteQueryState() {
|
||||||
const flat = key => (this[key] !== "" ? `${key}=${this[key]}&` : "")
|
const flat = (key) => (this[key] !== "" ? `${key}=${this[key]}&` : "")
|
||||||
const deep = key => {
|
const deep = (key) => {
|
||||||
const haveItems = [...this[key]].length
|
const haveItems = [...this[key]].length
|
||||||
if (haveItems && this[key]["value"] !== "") {
|
if (haveItems && this[key]["value"] !== "") {
|
||||||
return `${key}=${JSON.stringify(this[key])}&`
|
return `${key}=${JSON.stringify(this[key])}&`
|
||||||
@@ -2406,19 +2409,14 @@ export default {
|
|||||||
!this.urlExcludes.bearerToken ? "bearerToken" : null,
|
!this.urlExcludes.bearerToken ? "bearerToken" : null,
|
||||||
"contentType",
|
"contentType",
|
||||||
]
|
]
|
||||||
.filter(item => item !== null)
|
.filter((item) => item !== null)
|
||||||
.map(item => flat(item))
|
.map((item) => flat(item))
|
||||||
const deeps = ["headers", "params"].map(item => deep(item))
|
const deeps = ["headers", "params"].map((item) => deep(item))
|
||||||
const bodyParams = this.rawInput ? [flat("rawParams")] : [deep("bodyParams")]
|
const bodyParams = this.rawInput ? [flat("rawParams")] : [deep("bodyParams")]
|
||||||
history.replaceState(
|
history.replaceState(
|
||||||
window.location.href,
|
window.location.href,
|
||||||
"",
|
"",
|
||||||
`/?${encodeURI(
|
`/?${encodeURI(flats.concat(deeps, bodyParams).join("").slice(0, -1))}`
|
||||||
flats
|
|
||||||
.concat(deeps, bodyParams)
|
|
||||||
.join("")
|
|
||||||
.slice(0, -1)
|
|
||||||
)}`
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
setRouteQueries(queries) {
|
setRouteQueries(queries) {
|
||||||
@@ -2730,7 +2728,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.observeRequestButton()
|
this.observeRequestButton()
|
||||||
this._keyListener = function(e) {
|
this._keyListener = function (e) {
|
||||||
if (e.key === "g" && (e.ctrlKey || e.metaKey)) {
|
if (e.key === "g" && (e.ctrlKey || e.metaKey)) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.sendRequest()
|
this.sendRequest()
|
||||||
@@ -2762,7 +2760,7 @@ export default {
|
|||||||
}
|
}
|
||||||
if (Object.keys(this.$route.query).length) this.setRouteQueries(this.$route.query)
|
if (Object.keys(this.$route.query).length) this.setRouteQueries(this.$route.query)
|
||||||
this.$watch(
|
this.$watch(
|
||||||
vm => [
|
(vm) => [
|
||||||
vm.label,
|
vm.label,
|
||||||
vm.method,
|
vm.method,
|
||||||
vm.url,
|
vm.url,
|
||||||
@@ -2777,7 +2775,7 @@ export default {
|
|||||||
vm.contentType,
|
vm.contentType,
|
||||||
vm.rawParams,
|
vm.rawParams,
|
||||||
],
|
],
|
||||||
val => {
|
(val) => {
|
||||||
this.setRouteQueryState()
|
this.setRouteQueryState()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user