mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-19 01:26:08 +10:00
Make sure slashes are handled properly.
This commit is contained in:
@@ -102,6 +102,8 @@ module GitlabMarkdownHelper
|
||||
path.gsub!(/(#.*)/, "")
|
||||
id = $1 || ""
|
||||
file_path = relative_file_path(path)
|
||||
file_path = sanitize_slashes(file_path)
|
||||
|
||||
[
|
||||
Gitlab.config.gitlab.relative_url_root,
|
||||
@project.path_with_namespace,
|
||||
@@ -110,6 +112,12 @@ module GitlabMarkdownHelper
|
||||
].compact.join("/").gsub(/^\/*|\/*$/, '') + id
|
||||
end
|
||||
|
||||
def sanitize_slashes(path)
|
||||
path[0] = "" if path.start_with?("/")
|
||||
path.chop if path.end_with?("/")
|
||||
path
|
||||
end
|
||||
|
||||
def relative_file_path(path)
|
||||
requested_path = @path
|
||||
nested_path = build_nested_path(path, requested_path)
|
||||
|
||||
Reference in New Issue
Block a user