Sha256: 084883916d7456d09422ef6cd8d2b5fe59fe253262cb470530c6f1ae8ec9b2f1

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

module HTML
  class Pipeline
    # 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
    class HttpsFilter < Filter
      def call
        doc.css(%Q(a[href^="#{context[:base_url]}"])).each do |element|
          element['href'] = element['href'].sub(/^http:/,'https:')
        end
        doc
      end

      # Raise error if :base_url undefined
      def validate
        needs :base_url
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
html-pipeline-1.10.0 lib/html/pipeline/https_filter.rb
html-pipeline-1.9.0 lib/html/pipeline/https_filter.rb