diff options
Diffstat (limited to 'lib/utils.coffee')
| -rw-r--r-- | lib/utils.coffee | 12 | 
1 files changed, 6 insertions, 6 deletions
| diff --git a/lib/utils.coffee b/lib/utils.coffee index 00dce5b4..49481445 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -45,6 +45,12 @@ Utils =    # Tries to detect if :str is a valid URL.    isUrl: (str) -> +    # Starts with a scheme: URL +    return true if /^[a-z]{3,}:\/\//.test str + +    # Must not contain spaces +    return false if ' ' in str +      # More or less RFC compliant URL host part parsing. This should be sufficient for our needs      urlRegex = new RegExp(        '^(?:([^:]+)(?::([^:]+))?@)?' + # user:password (optional) => \1, \2 @@ -57,12 +63,6 @@ Utils =      specialHostNames = ['localhost'] -    # Starts with a scheme: URL -    return true if /^[a-z]{3,}:\/\//.test str - -    # Must not contain spaces -    return false if ' ' in str -      # Try to parse the URL into its meaningful parts. If matching fails we're pretty sure that we don't have      # some kind of URL here.      match = urlRegex.exec (str.split '/')[0] | 
