Class: HTML::Pipeline::HttpsFilter
- Defined in:
- lib/html/pipeline/https_filter.rb
Overview
HTML Filter for replacing http references to :http_url with https versions. Subdomain references are not rewritten.
Context options:
:http_url - The HTTP url to force HTTPS. Falls back to :base_url
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
- #call ⇒ Object
-
#http_url ⇒ Object
HTTP url to replace.
-
#validate ⇒ Object
Raise error if :http_url undefined.
Methods inherited from Filter
#base_url, call, #current_user, #doc, #has_ancestor?, #html, #initialize, #needs, #parse_html, #repository, #search_text_nodes, 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^="#{http_url}"])).each do |element| element['href'] = element['href'].sub(/^http:/,'https:') end doc end |
#http_url ⇒ Object
HTTP url to replace. Falls back to :base_url
17 18 19 |
# File 'lib/html/pipeline/https_filter.rb', line 17 def http_url context[:http_url] || context[:base_url] end |
#validate ⇒ Object
Raise error if :http_url undefined
22 23 24 |
# File 'lib/html/pipeline/https_filter.rb', line 22 def validate needs :http_url unless http_url end |