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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-08-02 09:54:28 +0300
committerRémy Coutable <remy@rymai.me>2016-08-02 09:54:28 +0300
commit632113e43cc3296759b11dc20b1b7f2f056278f0 (patch)
treecb6faef381fa3b122452366a70e40b1306139605 /lib
parentc009f620173df2bcce43670c61dfaaa845719ebe (diff)
parent40da543f2fddefcdebf12e52425314355a16a57d (diff)
Merge branch 'relative-markdown-links' into 'master'
Add support for relative links starting with ./ or / to RelativeLinkFilter ## What does this MR do? - Allow explicit relative links in Markdown (starting with `./`). - Allow absolute links (relative to the branch's root directory) in Markdown (starting with `/`). ## Why was this MR needed? Those link types were not supported before. ## What are the relevant issue numbers? fixes #19028 See merge request !5586
Diffstat (limited to 'lib')
-rw-r--r--lib/banzai/filter/relative_link_filter.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 337fb50317d..5b73fc8fcee 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -87,10 +87,13 @@ module Banzai
def build_relative_path(path, request_path)
return request_path if path.empty?
return path unless request_path
+ return path[1..-1] if path.start_with?('/')
parts = request_path.split('/')
parts.pop if uri_type(request_path) != :tree
+ path.sub!(%r{^\./}, '')
+
while path.start_with?('../')
parts.pop
path.sub!('../', '')