class Loofah::Scrubbers::NoOpener
scrub!(:noopener)¶ ↑
:noopener
adds a rel=“noopener” attribute to all links
link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>" Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener) => "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
Public Class Methods
new()
click to toggle source
# File lib/loofah/scrubbers.rb, line 226 def initialize # rubocop:disable Lint/MissingSuper @direction = :top_down end
Public Instance Methods
scrub(node)
click to toggle source
# File lib/loofah/scrubbers.rb, line 230 def scrub(node) return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == "a") append_attribute(node, "rel", "noopener") STOP end