Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-07-31 04:47:41 +0300
committerRobert Speicher <robert@gitlab.com>2015-07-31 04:47:41 +0300
commita51a3fb8ed92a58b375125b19f75c3d4c545571a (patch)
treed4483d8e96c64d4ae3f21224697e8f44d4696431 /lib
parent327013ace9933eaec75c7e41f5918a311e861d12 (diff)
parent7ca7770e984d802f9f35579d6b5c08ad63a3052a (diff)
Merge branch 'rs-mr-1050-followup' into 'master'
Add spec to RelativeLinkFilter for Unicode filenames Adds specs for changes added in !1050 See merge request !1078
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/relative_link_filter.rb13
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