diff options
Diffstat (limited to 'lib/banzai/filter/wiki_link_filter/rewriter.rb')
-rw-r--r-- | lib/banzai/filter/wiki_link_filter/rewriter.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/banzai/filter/wiki_link_filter/rewriter.rb b/lib/banzai/filter/wiki_link_filter/rewriter.rb index f4cc8beeb52..b4c2e7efae3 100644 --- a/lib/banzai/filter/wiki_link_filter/rewriter.rb +++ b/lib/banzai/filter/wiki_link_filter/rewriter.rb @@ -6,7 +6,7 @@ module Banzai class Rewriter def initialize(link_string, wiki:, slug:) @uri = Addressable::URI.parse(link_string) - @wiki_base_path = wiki && wiki.wiki_base_path + @wiki_base_path = wiki&.wiki_base_path @slug = slug end @@ -41,7 +41,8 @@ module Banzai # Any link _not_ of the form `http://example.com/` def apply_relative_link_rules! if @uri.relative? && @uri.path.present? - link = ::File.join(@wiki_base_path, @uri.path) + link = @uri.path + link = ::File.join(@wiki_base_path, link) unless link.starts_with?(@wiki_base_path) link = "#{link}##{@uri.fragment}" if @uri.fragment @uri = Addressable::URI.parse(link) end |