mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
setting to exclude rel nofollow from particular domains
This commit is contained in:
parent
80929ead4b
commit
f68f59c24f
4 changed files with 17 additions and 3 deletions
|
@ -180,6 +180,11 @@ module PrettyText
|
|||
end
|
||||
|
||||
def self.add_rel_nofollow_to_user_content(html)
|
||||
whitelist = []
|
||||
l = SiteSetting.exclude_rel_nofollow_domains
|
||||
if l.present?
|
||||
whitelist = l.split(",")
|
||||
end
|
||||
site_uri = nil
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
doc.css("a").each do |l|
|
||||
|
@ -188,7 +193,7 @@ module PrettyText
|
|||
uri = URI(href)
|
||||
site_uri ||= URI(Discourse.base_url)
|
||||
|
||||
if !uri.host.present? || uri.host.ends_with?(site_uri.host)
|
||||
if !uri.host.present? || uri.host.ends_with?(site_uri.host) || whitelist.any?{|u| uri.host.ends_with?(u)}
|
||||
# we are good no need for nofollow
|
||||
else
|
||||
l["rel"] = "nofollow"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue