-
-
Save vvvhung/d2284a1718594981076c00795adc0a3f to your computer and use it in GitHub Desktop.
Validate a URL to add http if needed (VueJS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validateUrl() { | |
let regex = /^(http|https)/; | |
if(this.url.length > 3 && !this.url.match(regex)) { | |
this.url = 'http://' + this.url; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment