Added protection against unsupported URLs

This commit is contained in:
Marcin Kurczewski 2014-08-03 22:34:30 +02:00
parent 26fcfa1bd9
commit 42d814656a

View file

@ -57,6 +57,18 @@ function bindUrlHandlerEvents()
url = url.replace(/^\s+|\s+$/, '');
if (url == '')
return;
protocol = /^(\w+):\/\//.exec(url)
if (!protocol)
url = 'http://' + url;
else
{
protocol = protocol[1].toLowerCase();
if (protocol != 'http' && protocol != 'https')
{
alert('Unsupported protocol: ' + protocol);
return;
}
}
$('#url-handler-wrapper input').val('');
addURLs([url]);
});