From aef6da8b7ba9fe9d34fe970acc2fde4b3347f64d Mon Sep 17 00:00:00 2001 From: raishvaria Date: Mon, 2 Dec 2019 11:49:41 +0530 Subject: [PATCH] add utilities --- resources/assets/js/helpers/utilities.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/assets/js/helpers/utilities.js b/resources/assets/js/helpers/utilities.js index 409b756f5..442af4c44 100644 --- a/resources/assets/js/helpers/utilities.js +++ b/resources/assets/js/helpers/utilities.js @@ -87,5 +87,16 @@ export default { } catch (e) { console.log(e) } + }, + + checkValidUrl (url) { + let pattern = new RegExp('^(https?:\\/\\/)?' + // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string + '(\\#[-a-z\\d_]*)?$', 'i') // fragment locator + + return !!pattern.test(url) } }