diff --git a/app/models/communication/website/page/with_path.rb b/app/models/communication/website/page/with_path.rb index b92c9d7635788e8d57924d31930d08eb5aa47b25..99b4692e3c6dbc8efee742b5d5a6185543c07d23 100644 --- a/app/models/communication/website/page/with_path.rb +++ b/app/models/communication/website/page/with_path.rb @@ -28,8 +28,9 @@ module Communication::Website::Page::WithPath def url 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.end_with?('/') ? website.url[0..-2] : website.url}#{Static.clean_path path}" + # do not use a global Static.clean_path here because url has protocol with 2 slashes! + # remove trailing slash if needed, because path begins with a slash + "#{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,