Merge requests fail where branch contains a # symbol

Summary

When we call GitLab: Crete new merge request on current branch command, branch with # doesn't get escaped causing incorrect branch name

Steps to reproduce

  1. Create test-#-hash branch and push a commit to the remote.
  2. Run GitLab: Crete new merge request on current branch command

What is the current bug behavior?

The branch name appears unescaped in the URL:

http://127.0.0.1:3000/root/empty-test-2/-/merge_requests/new?merge_request%5Bsource_branch%5D=test-#-hash

The #-hash gets treated as the browser ID fragment.

What is the expected correct behavior?

The # is encoded and we open the MR with the following URL:

http://127.0.0.1:3000/root/empty-test-2/-/merge_requests/new?merge_request[source_branch]=test-%23-hash

Relevant logs and/or screenshots

Screenshot_2020-08-05_at_11.14.34_AM

Possible fixes

Probably calling encodeURIComponent(branchName); is enough to fix the issue.

Edited by Tomas Vik (OOO back on 2026-01-05)