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:
evazion
2020-01-11 00:59:25 -06:00
parent 9afce59790
commit 07a0b0b175
3 changed files with 2 additions and 8 deletions

View File

@@ -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

View File

@@ -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}"

View File

@@ -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))