Commit 603e04bc21b07b8b6f70e972383ea2f29d0bfce0
1 parent
52c3179b
Exists in
spb-stable
and in
2 other branches
Make sure slashes are handled properly.
Showing
1 changed file
with
8 additions
and
0 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
... | ... | @@ -102,6 +102,8 @@ module GitlabMarkdownHelper |
102 | 102 | path.gsub!(/(#.*)/, "") |
103 | 103 | id = $1 || "" |
104 | 104 | file_path = relative_file_path(path) |
105 | + file_path = sanitize_slashes(file_path) | |
106 | + | |
105 | 107 | [ |
106 | 108 | Gitlab.config.gitlab.relative_url_root, |
107 | 109 | @project.path_with_namespace, |
... | ... | @@ -110,6 +112,12 @@ module GitlabMarkdownHelper |
110 | 112 | ].compact.join("/").gsub(/^\/*|\/*$/, '') + id |
111 | 113 | end |
112 | 114 | |
115 | + def sanitize_slashes(path) | |
116 | + path[0] = "" if path.start_with?("/") | |
117 | + path.chop if path.end_with?("/") | |
118 | + path | |
119 | + end | |
120 | + | |
113 | 121 | def relative_file_path(path) |
114 | 122 | requested_path = @path |
115 | 123 | nested_path = build_nested_path(path, requested_path) | ... | ... |