aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJez Ng2012-06-20 18:38:12 -0700
committerJez Ng2012-06-20 18:38:42 -0700
commit9976c25058e5154fc7e275d537a0d05d981aa15f (patch)
treec812151e2e1f4d867bbe30641db19dd8d6f24659 /lib
parent34f8f2dc389da77e206b8eef9e2505da3f169810 (diff)
downloadvimium-9976c25058e5154fc7e275d537a0d05d981aa15f.tar.bz2
Teach URL canonicalizer about 'view-source:' prefix.
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.coffee11
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