Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Rules
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2019-03-13 22:56:42 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2019-03-14 12:51:06 +0300
commit9d34353bf2da673adb843eac7443a3670243c4b8 (patch)
tree70d1d76651adfcd1eedf85dbeed78c8759b70b1e /Rules
parentc8dbfbfb002904a5a9b25b5370520f8ba18658f2 (diff)
Fix broken redirects
If there's a redirect_to defined, take it into account.
Diffstat (limited to 'Rules')
-rw-r--r--Rules10
1 files changed, 7 insertions, 3 deletions
diff --git a/Rules b/Rules
index 13e7ebed..c0809d4d 100644
--- a/Rules
+++ b/Rules
@@ -17,9 +17,13 @@ preprocess do
item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html')
end
else
- # If the provided relative URL is in Markdown, correct it to HTML.
- unless item[:redirect_to].to_s.match(/.html$/)
- item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html')
+ # If the provided path is in Markdown
+ if item[:redirect_to].to_s.match(/.md/)
+ # If it's not a full URL
+ unless item[:redirect_to].to_s.match(/^http/)
+ # Correct it to HTML
+ item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html')
+ end
end
end