Last active
June 29, 2020 03:31
-
-
Save foxted/201c990cd0128cb4aab34fd8a2789526 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
My solution: