Skip to content
Snippets Groups Projects
Commit d9c06fcf authored by pabois's avatar pabois
Browse files

factorize method

parent 1467fc8e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment