Commit 0fbc0cba authored by Tobias Schmidt's avatar Tobias Schmidt

Fix absolute links to markdown pages in repo docs

Absolute links to markdown pages should not be rendered relative.

Fixes prometheus/prometheus#4627
Signed-off-by: 's avatarTobias Schmidt <tobidt@gmail.com>
parent a882708b
# encoding: utf-8
require 'nokogiri'
require 'uri'
class NormalizeLinks < ::Nanoc::Filter
identifier :normalize_links
......@@ -18,7 +19,7 @@ class NormalizeLinks < ::Nanoc::Filter
when link['href'].start_with?('/')
# TODO(ts): It's not guaranteed that a repository is hosted on Github.
github_link_to(link['href'], config)
when link['href'].include?('.md')
when link['href'].include?('.md') && !URI.parse(link['href']).absolute?
relative_link_to(link['href'])
else
link['href']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment