openstreetmap-website/app/helpers/title_helper.rb
Tom Hughes e2aef40437 URI encode the X-Page-Title header
Browsers's are inconsistent in how they interpret the encoding
of a response header in an XHR request, so URI encode it so that
it simple ASCII we can then decode it again in the browser.
2015-03-17 18:49:39 +00:00

17 lines
474 B
Ruby

require "htmlentities"
module TitleHelper
def self.coder
@coder ||= HTMLEntities.new
end
def set_title(title = false)
if title
@title = TitleHelper.coder.decode(title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c"))
response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title") + " | " + @title)
else
@title = title
response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title"))
end
end
end