Class: HTML::Pipeline::RelativeLinksFilter
- Defined in:
- lib/html/pipeline/relative_links_filter.rb
Overview
HTML Filter for replacing http and https urls with protocol relative versions.
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
Methods inherited from Filter
#base_url, call, #current_user, #doc, #has_ancestor?, #html, #initialize, #needs, #parse_html, #repository, to_document, to_html, #validate
Constructor Details
This class inherits a constructor from HTML::Pipeline::Filter
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/html/pipeline/relative_links_filter.rb', line 7 def call h = context[:host] doc.css("a[href^=\"http://#{h}\"],a[href^=\"https://#{h}\"]").each do |element| element['href'] = element['href'].sub(/^https?:/, '') end doc end |