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:
authorMarcia Ramos <virtua.creative@gmail.com>2018-12-07 21:20:11 +0300
committerMarcia Ramos <virtua.creative@gmail.com>2018-12-07 21:20:11 +0300
commit6e294d3f197fc9cb743894c53cfcf3300ae34f41 (patch)
tree328ad6a3505defd2628652c811abaa833a0b1bfa /Rules
parentd5b7c6d9e72335c55f5fa32df9bde937d42e2bef (diff)
Revert "Merge branch 'redirect-check-md' into 'master'"
This reverts merge request !380
Diffstat (limited to 'Rules')
-rw-r--r--Rules18
1 files changed, 8 insertions, 10 deletions
diff --git a/Rules b/Rules
index 93d6423d..c59e75ed 100644
--- a/Rules
+++ b/Rules
@@ -7,21 +7,19 @@ preprocess do
@items.each do |item|
if item.identifier.to_s.end_with?(".md") && !item.binary?
- # Check if there is a 'redirect_to' defined in the yaml frontmatter.
- if item[:redirect_to]
- # If the provided URL is in Markdown, correct it to HTML.
- if item[:redirect_to].to_s.match(/.md$/)
- item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html')
- end
# If there isn't already a 'redirect_to' defined in the yaml frontmatter,
# use the text to assume the redirect URL.
- else
- # If the pattern 'This document was moved to [here](link)' is found.
+ unless item[:redirect_to]
if item.raw_content =~ /^This document was moved to \[.*\]\(.*\)/m
# Capture the intended page so the redirect page can redirect to it.
item[:redirect_to] = item.raw_content.match(/^This document was moved to \[.*\]\((.*)\)/m)[1]
- # If the provided URL is in Markdown, correct it to HTML.
- item[:redirect_to] = item[:redirect_to].gsub!(/\.md/, '.html') if item[:redirect_to].to_s.match(/.md/)
+ # Correct the URL.
+ 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')
end
end