diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index e4d996a3fb6de7050f0e53321435a0aa239a51d2..9b74364849e5e2c6251065930a9f145140dce548 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -113,17 +113,18 @@ module ExtractsPath
     @id = get_id
     @ref, @path = extract_ref(@id)
     @repo = @project.repository
-    if @options[:extended_sha1].blank?
-      @commit = @repo.commit(@ref)
-    else
-      @commit = @repo.commit(@options[:extended_sha1])
-    end
 
-    if @path.empty? && !@commit
-      @id = @ref = extract_ref_without_atom(@id)
+    if @options[:extended_sha1].present?
+      @commit = @repo.commit(@options[:extended_sha1])
+    else
       @commit = @repo.commit(@ref)
 
-      request.format = :atom if @commit
+      if @path.empty? && !@commit && @id.ends_with?('.atom')
+        @id = @ref = extract_ref_without_atom(@id)
+        @commit = @repo.commit(@ref)
+
+        request.format = :atom if @commit
+      end
     end
 
     raise InvalidPathError unless @commit