diff --git a/frontend/src/components/UI/AddRecipeFab.vue b/frontend/src/components/UI/AddRecipeFab.vue index 0a5230fec..62905e79b 100644 --- a/frontend/src/components/UI/AddRecipeFab.vue +++ b/frontend/src/components/UI/AddRecipeFab.vue @@ -7,10 +7,13 @@ - + @@ -64,18 +67,20 @@ export default { methods: { async createRecipe() { - this.processing = true; - let response = await api.recipes.createByURL(this.recipeURL); - if (response.status !== 201) { - this.error = true; - this.processing = false; - return; - } + if (this.$refs.urlForm.validate()) { + this.processing = true; + let response = await api.recipes.createByURL(this.recipeURL); + if (response.status !== 201) { + this.error = true; + this.processing = false; + return; + } - this.addRecipe = false; - this.processing = false; - this.recipeURL = ""; - this.$router.push(`/recipe/${response.data}`); + this.addRecipe = false; + this.processing = false; + this.recipeURL = ""; + this.$router.push(`/recipe/${response.data}`); + } }, navCreate() { @@ -89,6 +94,10 @@ export default { this.recipeURL = ""; 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"; + }, }, };