Class: HTML::Pipeline::HttpsFilter
- Defined in:
- lib/html/pipeline/https_filter.rb
Overview
HTML Filter for replacing http references to :base_url with https versions. Subdomain references are not rewritten.
Context options:
:base_url - The url to force https
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
- #call ⇒ Object
-
#validate ⇒ Object
Raise error if :base_url undefined.
Methods inherited from Filter
#base_url, call, #current_user, #doc, #has_ancestor?, #html, #initialize, #needs, #parse_html, #repository, to_document, to_html
Constructor Details
This class inherits a constructor from HTML::Pipeline::Filter
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 |
# File 'lib/html/pipeline/https_filter.rb', line 9 def call doc.css(%Q(a[href^="#{context[:base_url]}"])).each do |element| element['href'] = element['href'].sub(/^http:/,'https:') end doc end |
#validate ⇒ Object
Raise error if :base_url undefined
17 18 19 |
# File 'lib/html/pipeline/https_filter.rb', line 17 def validate needs :base_url end |