diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-02-18 17:40:16 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-02-18 17:40:16 +0000 |
commit | 544596681a79e5be1aa631c6c36b47072807f9e8 (patch) | |
tree | c14ca3ceffc5e3d84dadb7140b9bd6f4ff5e0a9a /app | |
parent | 0b8e41aae2d6d64d18d8034e863e72cc832d0b83 (diff) | |
parent | 15bee7e0ffa2f7eccd700da0238ad7a7e66ddbb0 (diff) | |
download | gitlab-ce-544596681a79e5be1aa631c6c36b47072807f9e8.tar.gz |
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.rb | 9 |
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) [ |