You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function isUrl(string) {
var urlRegexp = /^(https?://|ftps?://)?([a-z0-9%-]+.){1,}([a-z0-9-]+)?(:(\d{1,5}))?(/([a-z0-9-._~:/?#[]@!$&'()*+,;=%]+)?)?$/i;
return urlRegexp.test(string);
}
Since the protocol segment is set to be optional, the function will take strings like ""foo.bar"" as Url. Is this an expected behavior? Why not set the protocol segment required?
The text was updated successfully, but these errors were encountered:
I ran into a similar issue where decimal numbers inside a string were detected as URLs, e.g. "123.456". Requiring the protocol or at least the prefix www. seems like a good approach to me. Perhaps this could be supported through a separate mode that enforces a more strict definitions of URLs.
Hi! That's a good point. I'll enforce the presence of http(s) protocol for url detection.
There are other issues with url detection, such as anchors and query parameters, that should be fixed as well.
function isUrl(string) {
var urlRegexp = /^(https?://|ftps?://)?([a-z0-9%-]+.){1,}([a-z0-9-]+)?(:(\d{1,5}))?(/([a-z0-9-._~:/?#[]@!$&'()*+,;=%]+)?)?$/i;
return urlRegexp.test(string);
}
Since the protocol segment is set to be optional, the function will take strings like ""foo.bar"" as Url. Is this an expected behavior? Why not set the protocol segment required?
The text was updated successfully, but these errors were encountered: