if (xhr.getResponseHeader('X-Page-Title')) {
var title = xhr.getResponseHeader('X-Page-Title');
- document.title = decodeURIComponent(escape(title));
+ document.title = decodeURIComponent(title);
}
$('head')
def set_title(title = false)
if title
@title = TitleHelper.coder.decode(title.gsub("<bdi>", "\u202a").gsub("</bdi>", "\u202c"))
- response.headers["X-Page-Title"] = t("layouts.project_name.title") + " | " + @title
+ response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title") + " | " + @title)
else
@title = title
- response.headers["X-Page-Title"] = t("layouts.project_name.title")
+ response.headers["X-Page-Title"] = URI.escape(t("layouts.project_name.title"))
end
end
end
+# coding: utf-8
require "test_helper"
class TitleHelperTest < ActionView::TestCase
assert_nil @title
set_title("Test Title")
- assert_equal "OpenStreetMap | Test Title", response.header["X-Page-Title"]
+ assert_equal "OpenStreetMap%20%7C%20Test%20Title", response.header["X-Page-Title"]
assert_equal "Test Title", @title
set_title("Test & Title")
- assert_equal "OpenStreetMap | Test & Title", response.header["X-Page-Title"]
+ assert_equal "OpenStreetMap%20%7C%20Test%20&%20Title", response.header["X-Page-Title"]
assert_equal "Test & Title", @title
+
+ set_title("Tést & Tïtlè")
+ assert_equal "OpenStreetMap%20%7C%20T%C3%A9st%20&%20T%C3%AFtl%C3%A8", response.header["X-Page-Title"]
+ assert_equal "Tést & Tïtlè", @title
end
end