Skip to content

Instantly share code, notes, and snippets.

@vvvhung
Forked from foxted/validate-url.js
Created September 23, 2019 02:25
Show Gist options
  • Save vvvhung/d2284a1718594981076c00795adc0a3f to your computer and use it in GitHub Desktop.
Save vvvhung/d2284a1718594981076c00795adc0a3f to your computer and use it in GitHub Desktop.
Validate a URL to add http if needed (VueJS)
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