BigW Consortium Gitlab

Commit 603e04bc by Marin Jankovski

Make sure slashes are handled properly.

parent 52c3179b
...@@ -102,6 +102,8 @@ module GitlabMarkdownHelper ...@@ -102,6 +102,8 @@ module GitlabMarkdownHelper
path.gsub!(/(#.*)/, "") path.gsub!(/(#.*)/, "")
id = $1 || "" id = $1 || ""
file_path = relative_file_path(path) file_path = relative_file_path(path)
file_path = sanitize_slashes(file_path)
[ [
Gitlab.config.gitlab.relative_url_root, Gitlab.config.gitlab.relative_url_root,
@project.path_with_namespace, @project.path_with_namespace,
...@@ -110,6 +112,12 @@ module GitlabMarkdownHelper ...@@ -110,6 +112,12 @@ module GitlabMarkdownHelper
].compact.join("/").gsub(/^\/*|\/*$/, '') + id ].compact.join("/").gsub(/^\/*|\/*$/, '') + id
end end
def sanitize_slashes(path)
path[0] = "" if path.start_with?("/")
path.chop if path.end_with?("/")
path
end
def relative_file_path(path) def relative_file_path(path)
requested_path = @path requested_path = @path
nested_path = build_nested_path(path, requested_path) nested_path = build_nested_path(path, requested_path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment