diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index c091b2fc82..3b0e0022a2 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -1,2 +1,19 @@
module GroupsHelper
+
+ def link_to_ext(url)
+ link_to strip_url(url), ext_url(url), target: '_blank'
+ end
+
+ def ext_url(url)
+ if (url =~ /^https?:\/\//i)
+ return url
+ else
+ return 'http://' + url
+ end
+ end
+
+ def strip_url(url)
+ url.andand.sub(/^https?:\/\//i, '')
+ end
+
end
diff --git a/app/views/groups/_contact.html.haml b/app/views/groups/_contact.html.haml
index 0ed24b0d9d..e1bda90404 100644
--- a/app/views/groups/_contact.html.haml
+++ b/app/views/groups/_contact.html.haml
@@ -13,8 +13,7 @@
= @group.email
- if @group.website.present?
%p
- %a{href: @group.website, target: "_blank" }
- = @group.website
+ =link_to_ext @group.website
%div{bindonce: true}
- if @group.facebook.present?
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 08a4335bae..c9f44dd95a 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -1,15 +1,24 @@
require 'spec_helper'
-# Specs in this file have access to a helper object that includes
-# the GroupsHelper. For example:
-#
-# describe GroupsHelper do
-# describe "string concat" do
-# it "concats two strings with spaces" do
-# expect(helper.concat_strings("this","that")).to eq("this that")
-# end
-# end
-# end
describe GroupsHelper do
- pending "add some examples to (or delete) #{__FILE__}"
+ describe "ext_url" do
+ it "adds http:// if missing" do
+ expect(helper.ext_url("http://example.com/")).to eq("http://example.com/")
+ expect(helper.ext_url("https://example.com/")).to eq("https://example.com/")
+ expect(helper.ext_url("example.com")).to eq("http://example.com")
+ end
+ end
+ describe "strip_url" do
+ it "removes http(s)://" do
+ expect(helper.strip_url("http://example.com/")).to eq("example.com/")
+ expect(helper.strip_url("https://example.com/")).to eq("example.com/")
+ expect(helper.strip_url("example.com")).to eq("example.com")
+ end
+ end
+ describe "link_to_ext" do
+ it "gives a link to an html external url" do
+ expect(helper.link_to_ext("example.com")).to eq('example.com')
+ expect(helper.link_to_ext("https://example.com/")).to eq('example.com/')
+ end
+ end
end