Clean code.
This commit is contained in:
@@ -539,13 +539,7 @@
|
|||||||
return ['POST', 'PUT', 'PATCH'].includes(this.method);
|
return ['POST', 'PUT', 'PATCH'].includes(this.method);
|
||||||
},
|
},
|
||||||
pathName() {
|
pathName() {
|
||||||
let result;
|
return this.path.match(/^([^?]*)\??/)[1]
|
||||||
if(this.path.indexOf('?') !== -1) {
|
|
||||||
result = this.path.slice(0, this.path.indexOf('?'))
|
|
||||||
} else {
|
|
||||||
result = this.path;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
rawRequestBody() {
|
rawRequestBody() {
|
||||||
const {
|
const {
|
||||||
@@ -801,35 +795,33 @@
|
|||||||
this.response.body = "See JavaScript console (F12) for details.";
|
this.response.body = "See JavaScript console (F12) for details.";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pathInputHandler(event) {
|
getQueryStringFromPath() {
|
||||||
let newValue = event.target.value;
|
let path = this.path,
|
||||||
let path, start, end, queryString;
|
hashIndex = path.indexOf('#'),
|
||||||
path = newValue;
|
start = path.indexOf('?'),
|
||||||
start = path.indexOf('?');
|
end = hashIndex !== -1 ? hashIndex : path.length,
|
||||||
end = path.indexOf('#') !== -1 ? path.indexOf('#') : path.length;
|
queryString = '';
|
||||||
|
|
||||||
if(start !== -1) {
|
if(start !== -1) {
|
||||||
queryString = path.slice(start, end).length > 1 ? path.slice(start, end) : '';
|
let sliced = path.slice(start, end);
|
||||||
} else {
|
queryString = sliced.length > 1 ? sliced : '';
|
||||||
queryString = ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let params = [];
|
return queryString;
|
||||||
|
},
|
||||||
if(queryString) {
|
queryStringToArray(queryString) {
|
||||||
let paramsInString = newValue.split('?')[1];
|
return queryString.replace(/^\?/, '').split('&').filter(pair => !!pair).map(pair => {
|
||||||
params = paramsInString.split('&').filter(pair => !!pair).map(pair => {
|
let splited = pair.replace(/#/g, '').split('=');
|
||||||
pair = pair.replace(/#/g, '');
|
return {
|
||||||
let key, value;
|
key: splited.shift(),
|
||||||
if(pair.indexOf('=') === -1) {
|
value: splited.join('=')
|
||||||
key = pair;
|
|
||||||
value = '';
|
|
||||||
} else {
|
|
||||||
let splited = pair.split('=');
|
|
||||||
[key, value] = [splited.shift(), splited.join('=')];
|
|
||||||
}
|
}
|
||||||
return {key, value}
|
})
|
||||||
})
|
},
|
||||||
}
|
pathInputHandler() {
|
||||||
|
let queryString = this.getQueryStringFromPath(),
|
||||||
|
params = this.queryStringToArray(queryString);
|
||||||
|
|
||||||
this.paramsWatchEnabled = false;
|
this.paramsWatchEnabled = false;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user