Add spec for ext_url filter, refactor

This commit is contained in:
Rohan Mitchell
2015-02-23 10:03:03 +11:00
parent f8153c07b1
commit fdde55f631
2 changed files with 23 additions and 6 deletions

View File

@@ -1,9 +1,7 @@
Darkswarm.filter "ext_url", () ->
Darkswarm.filter "ext_url", ->
urlPattern = /^https?:\/\//
(url, prefix) ->
if (!url)
return url
if (url.match(urlPattern))
return url
if !url || url.match(urlPattern)
url
else
return prefix + url
prefix + url