formatting
This commit is contained in:
parent
f68f59c24f
commit
fd5f949116
|
@ -181,10 +181,12 @@ module PrettyText
|
||||||
|
|
||||||
def self.add_rel_nofollow_to_user_content(html)
|
def self.add_rel_nofollow_to_user_content(html)
|
||||||
whitelist = []
|
whitelist = []
|
||||||
|
|
||||||
l = SiteSetting.exclude_rel_nofollow_domains
|
l = SiteSetting.exclude_rel_nofollow_domains
|
||||||
if l.present?
|
if l.present?
|
||||||
whitelist = l.split(",")
|
whitelist = l.split(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
site_uri = nil
|
site_uri = nil
|
||||||
doc = Nokogiri::HTML.fragment(html)
|
doc = Nokogiri::HTML.fragment(html)
|
||||||
doc.css("a").each do |l|
|
doc.css("a").each do |l|
|
||||||
|
@ -193,7 +195,9 @@ module PrettyText
|
||||||
uri = URI(href)
|
uri = URI(href)
|
||||||
site_uri ||= URI(Discourse.base_url)
|
site_uri ||= URI(Discourse.base_url)
|
||||||
|
|
||||||
if !uri.host.present? || uri.host.ends_with?(site_uri.host) || whitelist.any?{|u| uri.host.ends_with?(u)}
|
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
|
# we are good no need for nofollow
|
||||||
else
|
else
|
||||||
l["rel"] = "nofollow"
|
l["rel"] = "nofollow"
|
||||||
|
|
Loading…
Reference in New Issue