diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-25 10:58:24 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-25 10:58:24 +0200 |
commit | 9f20580ed7338e72ffeadff86c0d605a2802c957 (patch) | |
tree | 8c220cc461d98aa5d795eb4e19f8ecacb5330fcb /app/helpers | |
parent | e1c00d5300065514965c8912b68edabc9d5a1879 (diff) | |
parent | 90bdcac6b17c0da762959dcfae3521f3be4606b7 (diff) | |
download | gitlab-ce-9f20580ed7338e72ffeadff86c0d605a2802c957.tar.gz |
Merge pull request #6375 from cirosantilli/link-with-id
Blob and tree gfm links to anchors work.
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index b25662e3ba2..6cad5e4658e 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -124,12 +124,14 @@ module GitlabMarkdownHelper end def rebuild_path(path_with_namespace, path, requested_path, ref) + path.gsub!(/(#.*)/, "") + id = $1 || "" file_path = relative_file_path(path, requested_path) [ path_with_namespace, path_with_ref(file_path, ref), file_path - ].compact.join("/") + ].compact.join("/").gsub(/\/*$/, '') + id end # Checks if the path exists in the repo @@ -154,6 +156,7 @@ module GitlabMarkdownHelper # If we are at doc/api and the README.md shown in below the tree view # this takes the rquest path(doc/api) and adds users.md so the path looks like doc/api/users.md def build_nested_path(path, request_path) + return request_path if path == "" return path unless request_path if local_path(request_path) == "tree" base = request_path.split("/").push(path) @@ -166,7 +169,7 @@ module GitlabMarkdownHelper end def file_exists?(path) - return false if path.nil? || path.empty? + return false if path.nil? return @repository.blob_at(current_sha, path).present? || @repository.tree(current_sha, path).entries.any? end |