config: eliminate hostnames config option.
Eliminate the Danbooru.config.hostnames option. It was only used for rewriting links in notes. Just using the main hostname is good enough, there aren't any notes still using any of Danbooru's alternate domain names.
This commit is contained in:
@@ -84,7 +84,7 @@ module NoteSanitizer
|
||||
|
||||
url = Addressable::URI.heuristic_parse(node["href"]).normalize
|
||||
|
||||
if url.authority.in?(Danbooru.config.hostnames)
|
||||
if url.authority == Danbooru.config.hostname
|
||||
url.site = nil
|
||||
node["href"] = url.to_s
|
||||
end
|
||||
|
||||
@@ -34,12 +34,6 @@ module Danbooru
|
||||
Socket.gethostname
|
||||
end
|
||||
|
||||
# The list of all domain names this site is accessible under.
|
||||
# Example: %w[danbooru.donmai.us sonohara.donmai.us hijiribe.donmai.us safebooru.donmai.us]
|
||||
def hostnames
|
||||
[hostname]
|
||||
end
|
||||
|
||||
# Contact email address of the admin.
|
||||
def contact_email
|
||||
"webmaster@#{server_host}"
|
||||
|
||||
@@ -23,7 +23,7 @@ class NoteSanitizerTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "rewrite absolute links to relative links" do
|
||||
Danbooru.config.stubs(:hostnames).returns(%w[danbooru.donmai.us sonohara.donmai.us hijiribe.donmai.us])
|
||||
Danbooru.config.stubs(:hostname).returns("sonohara.donmai.us")
|
||||
|
||||
body = '<a href="http://sonohara.donmai.us/posts?tags=touhou#dtext-intro">touhou</a>'
|
||||
assert_equal('<a href="/posts?tags=touhou#dtext-intro" rel="external noreferrer nofollow">touhou</a>', NoteSanitizer.sanitize(body))
|
||||
|
||||
Reference in New Issue
Block a user