diff options
| author | Jez Ng | 2012-06-20 18:38:12 -0700 | 
|---|---|---|
| committer | Jez Ng | 2012-06-20 18:38:42 -0700 | 
| commit | 9976c25058e5154fc7e275d537a0d05d981aa15f (patch) | |
| tree | c812151e2e1f4d867bbe30641db19dd8d6f24659 /lib/utils.coffee | |
| parent | 34f8f2dc389da77e206b8eef9e2505da3f169810 (diff) | |
| download | vimium-9976c25058e5154fc7e275d537a0d05d981aa15f.tar.bz2 | |
Teach URL canonicalizer about 'view-source:' prefix.
Diffstat (limited to 'lib/utils.coffee')
| -rw-r--r-- | lib/utils.coffee | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/lib/utils.coffee b/lib/utils.coffee index 6a846ae0..91d79c4c 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -32,9 +32,10 @@ Utils =    # Completes a partial URL (without scheme)    createFullUrl: (partialUrl) -> -    if (!/^[a-z]{3,}:\/\//.test(partialUrl)) -      partialUrl = "http://" + partialUrl -    partialUrl +    if (!/^[a-z]{3,}:\/\//.test(partialUrl)) and not /^view-source:/.test partialUrl +      "http://" + partialUrl +    else +      partialUrl    # Tries to detect, whether :str is a valid URL.    isUrl: (str) -> @@ -53,6 +54,10 @@ Utils =      # are there more?      specialHostNames = [ 'localhost' ] +    # special-case view-source:[url] +    if /^view-source:/.test str +      return true +      # it starts with a scheme, so it's definitely an URL      if (/^[a-z]{3,}:\/\//.test(str))        return true | 
