Commit 979ca7d6a288129253e3a187fb1058c707175681
1 parent
02484930
Exists in
master
and in
4 other branches
Correct check.
Showing
2 changed files
with
8 additions
and
5 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
| ... | ... | @@ -64,7 +64,9 @@ module GitlabMarkdownHelper |
| 64 | 64 | # ref - name of the branch or reference, eg. stable |
| 65 | 65 | # requested_path - path of request, eg. doc/api/README.md, used in special case when path is pointing to the .md file were the original request is coming from |
| 66 | 66 | # wiki - whether the markdown is from wiki or not |
| 67 | - def create_relative_links(text, project_path_with_namespace, ref, requested_path, wiki = false) | |
| 67 | + def create_relative_links(text, project, ref, requested_path, wiki = false) | |
| 68 | + @path_to_satellite = project.satellite.path | |
| 69 | + project_path_with_namespace = project.path_with_namespace | |
| 68 | 70 | paths = extract_paths(text) |
| 69 | 71 | paths.each do |file_path| |
| 70 | 72 | new_path = rebuild_path(project_path_with_namespace, file_path, requested_path, ref) |
| ... | ... | @@ -143,9 +145,10 @@ module GitlabMarkdownHelper |
| 143 | 145 | end |
| 144 | 146 | end |
| 145 | 147 | |
| 146 | - def file_exists?(path) | |
| 147 | - return false if path.nil? || path.empty? | |
| 148 | - File.exists?(Rails.root.join(path)) | |
| 148 | + def file_exists?(document_path) | |
| 149 | + return false if document_path.nil? || document_path.empty? | |
| 150 | + full_path = [@path_to_satellite, document_path].join("/") | |
| 151 | + File.exists?(full_path) | |
| 149 | 152 | end |
| 150 | 153 | |
| 151 | 154 | # Check if the path is pointing to a directory(tree) or a file(blob) | ... | ... |
lib/redcarpet/render/gitlab_html.rb
| ... | ... | @@ -36,7 +36,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML |
| 36 | 36 | |
| 37 | 37 | def preprocess(full_document) |
| 38 | 38 | if @project |
| 39 | - h.create_relative_links(full_document, @project.path_with_namespace, @ref, @request_path, is_wiki?) | |
| 39 | + h.create_relative_links(full_document, @project, @ref, @request_path, is_wiki?) | |
| 40 | 40 | else |
| 41 | 41 | full_document |
| 42 | 42 | end | ... | ... |