Updated main page url validation to use httpValid
This commit is contained in:
@@ -1339,6 +1339,8 @@ import {
|
|||||||
getQueryParams,
|
getQueryParams,
|
||||||
} from "../functions/requestParams.js"
|
} from "../functions/requestParams.js"
|
||||||
import { parseUrlAndPath } from "../functions/utils/uri.js"
|
import { parseUrlAndPath } from "../functions/utils/uri.js"
|
||||||
|
import { httpValid } from "../functions/utils/valid"
|
||||||
|
|
||||||
const statusCategories = [
|
const statusCategories = [
|
||||||
{
|
{
|
||||||
name: "informational",
|
name: "informational",
|
||||||
@@ -1858,18 +1860,8 @@ export default {
|
|||||||
return findStatusGroup(this.response.status)
|
return findStatusGroup(this.response.status)
|
||||||
},
|
},
|
||||||
isValidURL() {
|
isValidURL() {
|
||||||
if (this.showPreRequestScript) {
|
// if showPreRequestScript, we cannot determine if a URL is valid because the full string is not known ahead of time
|
||||||
// we cannot determine if a URL is valid because the full string is not known ahead of time
|
return this.showPreRequestScript || httpValid(this.url)
|
||||||
return true
|
|
||||||
}
|
|
||||||
const protocol = "^(https?:\\/\\/)?"
|
|
||||||
const validIP = new RegExp(
|
|
||||||
`${protocol}(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`
|
|
||||||
)
|
|
||||||
const validHostname = new RegExp(
|
|
||||||
`${protocol}(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9/])$`
|
|
||||||
)
|
|
||||||
return validIP.test(this.url) || validHostname.test(this.url)
|
|
||||||
},
|
},
|
||||||
hasRequestBody() {
|
hasRequestBody() {
|
||||||
return ["POST", "PUT", "PATCH"].includes(this.method)
|
return ["POST", "PUT", "PATCH"].includes(this.method)
|
||||||
|
|||||||
Reference in New Issue
Block a user