class Writeup::Filters::AbsoluteLinks
Public Instance Methods
call()
click to toggle source
# File lib/writeup/filters/absolute_links.rb, line 5 def call doc.search("a").each do |element| href = (element['href'] || '').strip next if href.nil? || href.blank? unless href.start_with?('http') || href.start_with?('//') || href.start_with?('#') element['href'] = URI.join(link_subpage_url, href).to_s end end doc end
link_subpage_url()
click to toggle source
Private: the relative url you want to use
# File lib/writeup/filters/absolute_links.rb, line 17 def link_subpage_url context[:link_subpage_url] or raise "Missing context :link_subpage_url for #{self.class.name}" end