diff --git a/app/helpers/url_helper.rb b/app/helpers/url_helper.rb index 6f623fcd..0f99a4a5 100644 --- a/app/helpers/url_helper.rb +++ b/app/helpers/url_helper.rb @@ -1,6 +1,6 @@ module UrlHelper def govuk_url_for(path) - (Plek.website_root + path).to_s + Addressable::URI.join(Plek.website_root, path).to_s end def short_url_manger_url_for(path) diff --git a/spec/helpers/url_helper_spec.rb b/spec/helpers/url_helper_spec.rb index ac13311e..5fd37ef0 100644 --- a/spec/helpers/url_helper_spec.rb +++ b/spec/helpers/url_helper_spec.rb @@ -5,6 +5,10 @@ it "should return a fully qualified gov.uk url from the given path" do expect(govuk_url_for("/some/path")).to eql "http://www.dev.gov.uk/some/path" end + + it "should leave absolute URLs unchanged" do + expect(govuk_url_for("http://example.com/some/other/path")).to eql "http://example.com/some/other/path" + end end describe "short_url_manger_url_for" do