diff --git a/app/models/communication/website/page/with_path.rb b/app/models/communication/website/page/with_path.rb index 58ba6ca3bdeac1db9f00d6539d0b3c018c310449..eea5969a3152c7d93981c6998850ab66e675a589 100644 --- a/app/models/communication/website/page/with_path.rb +++ b/app/models/communication/website/page/with_path.rb @@ -29,10 +29,8 @@ module Communication::Website::Page::WithPath return unless published return if website.url.blank? # do not use a global Static.clean here because url has protocol with 2 slashes! - website_url = website.url # remove trailing slash if needed, because path begins with a slash - website_url = website_url[0..-2] if website_url.end_with?('/') - "#{website_url}#{Static.clean_path path}" + "#{Static.remove_trailing_slash website.url}#{Static.clean_path path}" end protected diff --git a/app/services/static.rb b/app/services/static.rb index 6728ae1d96705bcf5e1688d672dd2779ffe6b0f7..f74f72c2fca26feb70671fd54c06155833bad5f6 100644 --- a/app/services/static.rb +++ b/app/services/static.rb @@ -4,6 +4,11 @@ class Static path.gsub("//", '/') end + def self.remove_trailing_slash(string) + string = string[0..-2] if string.end_with?('/') + string + end + def self.render(template_static, about, website) code = ApplicationController.render( template: template_static,