Sha256: 04b3826c104e949ec5caaed3af42f6e8cf6ff551d8d28b1c37baf8c55c86b4bb

Contents?: true

Size: 731 Bytes

Versions: 16

Compression:

Stored size: 731 Bytes

Contents

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

      # HTTP url to replace. Falls back to :base_url
      def http_url
        context[:http_url] || context[:base_url]
      end

      # Raise error if :http_url undefined
      def validate
        needs :http_url unless http_url
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
html-pipeline-2.7.1 lib/html/pipeline/https_filter.rb
html-pipeline-2.7.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.6.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.5.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.4.2 lib/html/pipeline/https_filter.rb
html-pipeline-2.4.1 lib/html/pipeline/https_filter.rb
html-pipeline-2.4.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.3.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.2.4 lib/html/pipeline/https_filter.rb
html-pipeline-2.2.3 lib/html/pipeline/https_filter.rb
html-pipeline-2.2.2 lib/html/pipeline/https_filter.rb
html-pipeline-2.2.1 lib/html/pipeline/https_filter.rb
html-pipeline-2.2.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.1.0 lib/html/pipeline/https_filter.rb
html-pipeline-2.0 lib/html/pipeline/https_filter.rb
html-pipeline-1.11.0 lib/html/pipeline/https_filter.rb