diff options
Diffstat (limited to 'lib/utils.coffee')
| -rw-r--r-- | lib/utils.coffee | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/lib/utils.coffee b/lib/utils.coffee index e2ed8d98..62749496 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -33,17 +33,18 @@ Utils =            return true if url.startsWith prefix        false +  hasFullUrlPrefix: do -> +    urlPrefix = new RegExp "^[a-z]{3,}://." +    (url) -> urlPrefix.test url +    # Completes a partial URL (without scheme)    createFullUrl: (partialUrl) -> -    unless /^[a-z]{3,}:\/\//.test partialUrl -      "http://" + partialUrl -    else -      partialUrl +    if @hasFullUrlPrefix(partialUrl) then partialUrl else ("http://" + partialUrl)    # Tries to detect if :str is a valid URL.    isUrl: (str) ->      # Starts with a scheme: URL -    return true if /^[a-z]{3,}:\/\//.test str +    return true if @hasFullUrlPrefix str      # Must not contain spaces      return false if ' ' in str | 
