diff options
| author | Robert Speicher <rspeicher@gmail.com> | 2015-07-30 17:25:07 -0400 |
|---|---|---|
| committer | Robert Speicher <rspeicher@gmail.com> | 2015-07-30 17:25:07 -0400 |
| commit | 4e22dcb6a34f43e5b3b2700ec72b32354315adc0 (patch) | |
| tree | 3e9171bfad132e20d7d5a1c26452c88d4b327d7b /lib | |
| parent | 6d6f807b759d13d111202129d8be2c88d7be819f (diff) | |
| download | gitlab-ce-4e22dcb6a34f43e5b3b2700ec72b32354315adc0.tar.gz | |
Add spec to RelativeLinkFilter for Unicode filenames
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/markdown/relative_link_filter.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/gitlab/markdown/relative_link_filter.rb b/lib/gitlab/markdown/relative_link_filter.rb index 3eaceba5323..30f50b82996 100644 --- a/lib/gitlab/markdown/relative_link_filter.rb +++ b/lib/gitlab/markdown/relative_link_filter.rb @@ -99,15 +99,24 @@ module Gitlab # Returns a String def path_type(path) unescaped_path = Addressable::URI.unescape(path) - if repository.tree(current_sha, unescaped_path).entries.any? + + if tree?(unescaped_path) 'tree' - elsif repository.blob_at(current_sha, unescaped_path).try(:image?) + elsif image?(unescaped_path) 'raw' else 'blob' end end + def tree?(path) + repository.tree(current_sha, path).entries.any? + end + + def image?(path) + repository.blob_at(current_sha, path).try(:image?) + end + def current_sha context[:commit].try(:id) || ref ? repository.commit(ref).try(:sha) : repository.head_commit.sha |
