Branch API fails if branch contains '/'
Summary
In the GitLab API, branches with '/' character in name are individually inaccessible by typical means. This is particularly noticeable when attempting to assess many projects with many branches.
Steps to Reproduce
In any project, create a branch with '/' in the name such as "initial/test". Using the API, attempt to get the newly created branch. When using a valid token, this request returns a 404 error. For typical branches, the branch information is returned.
Example Project
https://gitlab.com/trevonmchansen/My-Test-Project
What is the current bug behavior?
When accessing single project branch via API wherein branch name contains '/', receive error 404:
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.com/api/v4/projects/22469075/repository/branches/intial/test"
_Note: This is {"error":"404 Not Found"}, not {"message":"404 Branch Not Found"}
What is the expected correct behavior?
Return branch API information regardless of branch name.
Output of Checks
This bug only happens when accessing branches via GitLab API, or when visiting the branch path given via the API.
Possible Fixes
Could be remedied by checking branch name for special characters and URL-encoding.
Should note that if visiting the API via browser:
- This path: https://gitlab.com/api/v4/projects/22469075/repository/branches/inital/test
- Does not work
- This path: https://gitlab.com/api/v4/projects/22469075/repository/branches/inital%2Ftest
- Does work