aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Liesén2012-09-05 09:18:13 +0200
committerJohan Liesén2012-09-05 09:18:13 +0200
commitf9af8019e58a0a9cdc53c3cc96a7938376d089f5 (patch)
tree721335f771ab01e80682e95e78e282d23bbe42a0
parent164f7919ba625717a41948726c387b31a494aff9 (diff)
downloadvimium-f9af8019e58a0a9cdc53c3cc96a7938376d089f5.tar.bz2
Wrap lines at 110 chars
-rw-r--r--lib/utils.coffee26
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 9ddab62f..c43a283c 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -45,8 +45,7 @@ Utils =
# Tries to detect if :str is a valid URL.
isUrl: (str) ->
- # More or less RFC compliant URL host part parsing. This should be
- # sufficient for our needs
+ # More or less RFC compliant URL host part parsing. This should be sufficient for our needs
urlRegex = new RegExp(
# user:password (optional) => \1, \2
'^(?:([^:]+)(?::([^:]+))?@)?' +
@@ -78,8 +77,8 @@ Utils =
# Must not contain spaces
return false if ' ' in str
- # Try to parse the URL into its meaningful parts. If matching fails we're
- # pretty sure that we don't have some kind of URL here.
+ # Try to parse the URL into its meaningful parts. If matching fails we're pretty sure that we don't have
+ # some kind of URL here.
match = urlRegex.exec (str.split '/')[0]
return false unless match
hostName = match[3]
@@ -87,14 +86,12 @@ Utils =
# Allow known special host names
return true if hostName in specialHostNames
- # Allow IPv6 addresses (need to be wrapped in brackets as required by
- # RFC). It is sufficient to check for a colon, as the regex wouldn't
- # match colons in the host name unless it's an v6 address
+ # Allow IPv6 addresses (need to be wrapped in brackets as required by RFC). It is sufficient to check for
+ # a colon, as the regex wouldn't match colons in the host name unless it's an v6 address
return true if ':' in hostName
- # At this point we have to make a decision. As a heuristic, we check
- # if the input has dots in it. If yes, and if the last part could be a
- # TLD, treat it as an URL
+ # At this point we have to make a decision. As a heuristic, we check if the input has dots in it. If yes,
+ # and if the last part could be a TLD, treat it as an URL
dottedParts = hostName.split '.'
if dottedParts.length > 1
@@ -112,8 +109,8 @@ Utils =
# Escape explicitely to encode characters like "+" correctly
"http://www.google.com/search?q=" + encodeURIComponent(query)
- # Converts :string into a Google search if it's not already a URL. We
- # don't bother with escaping characters as Chrome will do that for us.
+ # Converts :string into a Google search if it's not already a URL. We don't bother with escaping characters
+ # as Chrome will do that for us.
convertToUrl: (string) ->
string = string.trim()
@@ -125,9 +122,8 @@ Utils =
else
Utils.createSearchUrl string
-# This creates a new function out of an existing function, where the new
-# function takes fewer arguments. This allows us to pass around functions
-# instead of functions + a partial list of arguments.
+# This creates a new function out of an existing function, where the new function takes fewer arguments. This
+# allows us to pass around functions instead of functions + a partial list of arguments.
Function::curry = ->
fixedArguments = Array.copy(arguments)
fn = this