URL is broken when switching from branch with longer name to branch with shorter name in Gitlab Web GUI
Summary
Any project with branches named with similar initials like [ development and dev ] or [ production and prod ] will have issues when switching from branch with a longer name to branch with a shorter name for example [ development to dev ] or [ production to dev ] branch in the Gitlab Web GUI.
Steps to reproduce
- Create a gitlab project
- Create a branch "development" from master
- Create another branch "dev"
- Switch to "development" branch from the dropdown in the Repository/Commits section of Gitlab Web GUI
- Switch to "dev" branch
Example Project
https://gitlab.com/edocabhi/gitlab-bug
Reproducing in Sample Project
- Visit https://gitlab.com/edocabhi/gitlab-bug/-/commits/production
- Switch to dev or prod branch from the dropdown
What is the current bug behavior?
- When the switch is done in Repository/Commits section it takes the user to 404 page.
- When the switch is done in Repository/Files section it gives an information bar for nonexistent path as shown in attached screenshot
-
Initially when in development branch the URL will look like this
https://gitlab.com/ativiti1/ativiti/-/commits/development
-
When switched to dev branch the URL becomes
https://gitlab.com/ativiti1/ativiti/-/commits/dev/lopment
-
Similarly switching from production to dev results in another broken URL
https://gitlab.com/edocabhi/gitlab-bug/-/commits/dev/ction
Behavior Summary: When switching from a long branch name to a shorter branch name the trailing character is attached to the new URL and thus making it a broken URL
What is the expected correct behavior?
The branch should be switched seamlessly without any issues
Relevant logs and/or screenshots
Possible Fix
The URL generator for switching branches needs to be adapted and the trailing characters from the referral link need to be removed from the newly generated URL