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/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-02-18 20:40:16 +0300
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-02-18 20:40:16 +0300
commit544596681a79e5be1aa631c6c36b47072807f9e8 (patch)
treec14ca3ceffc5e3d84dadb7140b9bd6f4ff5e0a9a /app
parent0b8e41aae2d6d64d18d8034e863e72cc832d0b83 (diff)
parent15bee7e0ffa2f7eccd700da0238ad7a7e66ddbb0 (diff)
Merge branch 'fix-relative-anchored-links' into 'master'
Fix Markdown relative links to files with anchors. Fixes #2016. cc @marin See merge request !1541
Diffstat (limited to 'app')
-rw-r--r--app/helpers/gitlab_markdown_helper.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 800cacdc2c2..ab30f498c01 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -110,7 +110,7 @@ module GitlabMarkdownHelper
end
def link_to_ignore?(link)
- if link =~ /\#\w+/
+ if link =~ /\A\#\w+/
# ignore anchors like <a href="#my-header">
true
else
@@ -122,10 +122,11 @@ module GitlabMarkdownHelper
["http://","https://", "ftp://", "mailto:"]
end
- def rebuild_path(path)
- path.gsub!(/(#.*)/, "")
+ def rebuild_path(file_path)
+ file_path = file_path.dup
+ file_path.gsub!(/(#.*)/, "")
id = $1 || ""
- file_path = relative_file_path(path)
+ file_path = relative_file_path(file_path)
file_path = sanitize_slashes(file_path)
[