From 9976c25058e5154fc7e275d537a0d05d981aa15f Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Wed, 20 Jun 2012 18:38:12 -0700 Subject: Teach URL canonicalizer about 'view-source:' prefix. --- lib/utils.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/utils.coffee') 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 -- cgit v1.2.3