diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb
index f58ba2b3eaf386ffa2a2814da4c305ed148bdbe8..5699389e0005c038a964483bdbc23f69e0741796 100644
--- a/app/presenters/blob_presenter.rb
+++ b/app/presenters/blob_presenter.rb
@@ -77,7 +77,7 @@ def replace_path
   end
 
   def pipeline_editor_path
-    project_ci_pipeline_editor_path(project, branch_name: blob.commit_id) if can_collaborate_with_project?(project) && blob.path == project.ci_config_path_or_default
+    project_ci_pipeline_editor_path(project, branch_name: commit_id) if can_collaborate_with_project?(project) && blob.path == project.ci_config_path_or_default
   end
 
   def gitpod_blob_url
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb
index 00a2c218466d9e93e79aea5fb80b8502b69df71a..12f3b4bb94a509bafe2f847426ea43d69c2b1b77 100644
--- a/spec/presenters/blob_presenter_spec.rb
+++ b/spec/presenters/blob_presenter_spec.rb
@@ -130,7 +130,7 @@
 
   describe '#pipeline_editor_path' do
     context 'when blob is .gitlab-ci.yml' do
-      before do
+      before_all do
         project.repository.create_file(
           user,
           '.gitlab-ci.yml',
@@ -144,6 +144,16 @@
       let(:path) { '.gitlab-ci.yml' }
 
       it { expect(presenter.pipeline_editor_path).to eq("/#{project.full_path}/-/ci/editor?branch_name=#{ref}") }
+
+      context 'when ref includes the qualifier' do
+        let(:ref) { 'refs/heads/main' }
+
+        it 'returns path to unqualified ref' do
+          allow(blob).to receive(:ref_type).and_return('heads')
+
+          expect(presenter.pipeline_editor_path).to eq("/#{project.full_path}/-/ci/editor?branch_name=main")
+        end
+      end
     end
   end