summaryrefslogtreecommitdiff
path: root/lib/extracts_path.rb
diff options
context:
space:
mode:
authorValeriy Sizov <vsv2711@gmail.com>2012-10-04 19:31:31 +0300
committerValeriy Sizov <vsv2711@gmail.com>2012-10-04 19:31:31 +0300
commite25ddca0c462522703af93822863023f4a754390 (patch)
treef78e55b656837b7f144cb14e57243b19d104d7f0 /lib/extracts_path.rb
parent73d5e51a2df5757d2eaf4ca9b54d05b48da8e15f (diff)
downloadgitlab-ce-e25ddca0c462522703af93822863023f4a754390.tar.gz
Fix bug with branches whose name contains slash
Diffstat (limited to 'lib/extracts_path.rb')
-rw-r--r--lib/extracts_path.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index f36dae5289b..020ff5cdf14 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -56,22 +56,22 @@ module ExtractsPath
# Append a trailing slash if we only get a ref and no file path
id = input
- id += '/' unless id.include?('/')
-
+ id += '/' unless id.ends_with?('/')
+
valid_refs = @project.branches + @project.tags
- valid_refs.select! { |v| id.start_with?("#{v}/") }
-
+ valid_refs.select! { |v| id.start_with?("#{v.name}/") }
+
if valid_refs.length != 1
# No exact ref match, so just try our best
pair = id.match(/([^\/]+)(.*)/).captures
else
# Partition the string into the ref and the path, ignoring the empty first value
- pair = id.partition(valid_refs.first)[1..-1]
+ pair = id.partition(valid_refs.first.name)[1..-1]
end
end
- # Remove leading slash from path
- pair[1].gsub!(/^\//, '')
+ # Remove ending slashes from path
+ pair[1].gsub!(/^\/|\/$/, '')
pair
end