diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 020ff5cdf14814c9f5373efc560dde838f08eb47..b60dfd036e1568540703f12a294dba60dd6cb146 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -57,16 +57,16 @@ module ExtractsPath
       # Append a trailing slash if we only get a ref and no file path
       id = input
       id += '/' unless id.ends_with?('/')
-      
-      valid_refs = @project.branches + @project.tags
-      valid_refs.select! { |v| id.start_with?("#{v.name}/") }
-      
+
+      valid_refs = @project.ref_names
+      valid_refs.select! { |v| id.start_with?("#{v}/") }
+
       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.name)[1..-1]
+        pair = id.partition(valid_refs.first)[1..-1]
       end
     end
 
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb
index 3ee729c93e89783c20323ebf07af485a7c8f89e5..cf4220175a78ec630d1e922b8ae7d1bd4620fbd9 100644
--- a/spec/lib/extracts_path_spec.rb
+++ b/spec/lib/extracts_path_spec.rb
@@ -7,8 +7,7 @@ describe ExtractsPath do
 
   before do
     @project = project
-    project.stub(:branches).and_return([stub(name: 'master'), stub(name: 'foo/bar/baz')])
-    project.stub(:tags).and_return([stub(name: 'master'), stub(name: 'master')])
+    project.stub(:ref_names).and_return(['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0'])
   end
 
   describe '#extract_ref' do