mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
url validation
This commit is contained in:
parent
4de7bd8016
commit
9e91f05df8
1 changed files with 21 additions and 12 deletions
|
@ -7,10 +7,13 @@
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-form>
|
<v-form ref="urlForm">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="recipeURL"
|
v-model="recipeURL"
|
||||||
:label="$t('new-recipe.recipe-url')"
|
:label="$t('new-recipe.recipe-url')"
|
||||||
|
required
|
||||||
|
validate-on-blur
|
||||||
|
:rules="[isValidWebUrl]"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-form>
|
</v-form>
|
||||||
|
|
||||||
|
@ -64,18 +67,20 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async createRecipe() {
|
async createRecipe() {
|
||||||
this.processing = true;
|
if (this.$refs.urlForm.validate()) {
|
||||||
let response = await api.recipes.createByURL(this.recipeURL);
|
this.processing = true;
|
||||||
if (response.status !== 201) {
|
let response = await api.recipes.createByURL(this.recipeURL);
|
||||||
this.error = true;
|
if (response.status !== 201) {
|
||||||
this.processing = false;
|
this.error = true;
|
||||||
return;
|
this.processing = false;
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.addRecipe = false;
|
this.addRecipe = false;
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
this.recipeURL = "";
|
this.recipeURL = "";
|
||||||
this.$router.push(`/recipe/${response.data}`);
|
this.$router.push(`/recipe/${response.data}`);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
navCreate() {
|
navCreate() {
|
||||||
|
@ -89,6 +94,10 @@ export default {
|
||||||
this.recipeURL = "";
|
this.recipeURL = "";
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
},
|
},
|
||||||
|
isValidWebUrl(url) {
|
||||||
|
let regEx = /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/gm;
|
||||||
|
return regEx.test(url) ? true : "Must be a Valid URL";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue