From a61d69ea40c9f2683107416eccab8046ab00c87d Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 2 Nov 2014 06:00:20 +0000 Subject: Refactor Utils.hasChromePrefix and add tests. --- lib/utils.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/utils.coffee') diff --git a/lib/utils.coffee b/lib/utils.coffee index 222b784b..bbcee1a0 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -25,11 +25,13 @@ Utils = id = 0 -> id += 1 - hasChromePrefix: (url) -> + hasChromePrefix: do -> chromePrefixes = [ "about:", "view-source:", "chrome-extension:", "data:" ] - for prefix in chromePrefixes - return true if url.startsWith prefix - false + (url) -> + if 0 < url.indexOf ":" + for prefix in chromePrefixes + return true if url.startsWith prefix + false # Completes a partial URL (without scheme) createFullUrl: (partialUrl) -> -- cgit v1.2.3