Skip to content

Commit

Permalink
add utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
raishvaria committed Dec 2, 2019
1 parent 0fb14af commit aef6da8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions resources/assets/js/helpers/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit aef6da8

Please sign in to comment.