Class: Rack::Relations::Processor
- Inherits:
-
Object
- Object
- Rack::Relations::Processor
- Defined in:
- lib/rack/relations/processor.rb
Instance Attribute Summary collapse
-
#safelist_domains ⇒ Object
TODO rename safelist_domains, might have other safelists?.
Instance Method Summary collapse
-
#initialize(safelist_domains:) ⇒ Processor
constructor
A new instance of Processor.
- #perform(body) ⇒ Object
Constructor Details
#initialize(safelist_domains:) ⇒ Processor
Returns a new instance of Processor.
9 10 11 |
# File 'lib/rack/relations/processor.rb', line 9 def initialize(safelist_domains:) @safelist_domains = safelist_domains end |
Instance Attribute Details
#safelist_domains ⇒ Object
TODO rename safelist_domains, might have other safelists?
7 8 9 |
# File 'lib/rack/relations/processor.rb', line 7 def safelist_domains @safelist_domains end |
Instance Method Details
#perform(body) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/relations/processor.rb', line 13 def perform(body) doc = parsed_body(body.join("\n")) doc.css("a[href]").each do |node| anchor = Anchor.new(node, safelist_domains: safelist_domains) next if anchor.safe? node.set_attribute("rel", anchor.modified_rel) end [doc.to_html] end |