Sha256: 92125dcb46ae6611b7c1865eede404486bdbf81071d4bde60d4eefdf1e12c7d9

Contents?: true

Size: 403 Bytes

Versions: 40

Compression:

Stored size: 403 Bytes

Contents

module HTML
  class Pipeline

    # HTML Filter for replacing http and https urls with protocol relative versions.
    class RelativeLinksFilter < Filter

      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

    end

  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
html-pipeline-linuxfr-0.15.7 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.6 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.5 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.4 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.3 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.30 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.2 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.1 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.29 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.15.0 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.28 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.27 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.26 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.25 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.24 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.23 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.22 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.21 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.20 lib/html/pipeline/relative_links_filter.rb
html-pipeline-linuxfr-0.14.19 lib/html/pipeline/relative_links_filter.rb