Added validation for URL

This commit is contained in:
Andrew Bastin
2019-08-22 20:11:08 +05:30
parent 362ab73026
commit a59aba453f
3 changed files with 23 additions and 2 deletions

View File

@@ -29,6 +29,11 @@ const app = new Vue({
history: window.localStorage.getItem("history") ? JSON.parse(window.localStorage.getItem("history")) : []
},
computed: {
urlNotValid() {
return !(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g.test(this.url))
},
rawRequestBody() {
const {
bodyParams
@@ -86,6 +91,12 @@ const app = new Vue({
document.getElementsByClassName(el)[0].classList.toggle('hidden')
},
sendRequest() {
if (this.urlNotValid) {
alert("Please check the formatting of the URL")
return
}
const n = new Date().toLocaleTimeString()
// Latest requests should be placed on top