Class: Banzai::Filter::AbsoluteLinkFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/absolute_link_filter.rb

Overview

HTML filter that converts relative urls into absolute ones.

Constant Summary collapse

CSS =
'a.gfm'
XPATH =
Gitlab::Utils::Nokogiri.css_to_xpath(CSS).freeze

Instance Method Summary collapse

Instance Method Details

#callObject


12
13
14
15
16
17
18
19
20
# File 'lib/banzai/filter/absolute_link_filter.rb', line 12

def call
  return doc unless context[:only_path] == false

  doc.xpath(XPATH).each do |el|
    process_link_attr el.attribute('href')
  end

  doc
end