Commit 979ca7d6 authored by Marin Jankovski's avatar Marin Jankovski

Correct check.

parent 02484930
...@@ -64,7 +64,9 @@ module GitlabMarkdownHelper ...@@ -64,7 +64,9 @@ module GitlabMarkdownHelper
# ref - name of the branch or reference, eg. stable # ref - name of the branch or reference, eg. stable
# 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 # 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
# wiki - whether the markdown is from wiki or not # wiki - whether the markdown is from wiki or not
def create_relative_links(text, project_path_with_namespace, ref, requested_path, wiki = false) def create_relative_links(text, project, ref, requested_path, wiki = false)
@path_to_satellite = project.satellite.path
project_path_with_namespace = project.path_with_namespace
paths = extract_paths(text) paths = extract_paths(text)
paths.each do |file_path| paths.each do |file_path|
new_path = rebuild_path(project_path_with_namespace, file_path, requested_path, ref) new_path = rebuild_path(project_path_with_namespace, file_path, requested_path, ref)
...@@ -143,9 +145,10 @@ module GitlabMarkdownHelper ...@@ -143,9 +145,10 @@ module GitlabMarkdownHelper
end end
end end
def file_exists?(path) def file_exists?(document_path)
return false if path.nil? || path.empty? return false if document_path.nil? || document_path.empty?
File.exists?(Rails.root.join(path)) full_path = [@path_to_satellite, document_path].join("/")
File.exists?(full_path)
end end
# Check if the path is pointing to a directory(tree) or a file(blob) # Check if the path is pointing to a directory(tree) or a file(blob)
......
...@@ -36,7 +36,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML ...@@ -36,7 +36,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def preprocess(full_document) def preprocess(full_document)
if @project if @project
h.create_relative_links(full_document, @project.path_with_namespace, @ref, @request_path, is_wiki?) h.create_relative_links(full_document, @project, @ref, @request_path, is_wiki?)
else else
full_document full_document
end end
......
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