Skip to content

Instantly share code, notes, and snippets.

@akhr
Created August 11, 2015 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhr/717fb84d4bc2c81ffa43 to your computer and use it in GitHub Desktop.
Save akhr/717fb84d4bc2c81ffa43 to your computer and use it in GitHub Desktop.
surl = 'sdf:/900';
url = surl.toLowerCase();
var arr = url.split("://");
var protocol = arr[0];
console.log('protocol - '+protocol);
if(protocol === 'https')
{
console.log('Its HTTPS');
}
else if(protocol === 'http')
{
console.log('Its HTTP :(');
}
else if( protocol === url)
{
if(url.match(/^[a-zA-Z0-9]{1}/)){
console.log('URL - '+'https://'+url);
}else{
console.log('Invalid');
}
}
else
{
console.log('Invalid');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment