Breadcrumb links in tree views are incorrect for installations configured with relative URLs
Summary
When GitLab is configured with a relative URL, the breadcrumb navigation links for a tree view do not include the correct path for deeply nested resources.
Steps to reproduce
- Configure GitLab with a relative URL (e.g.
external_url "https://example.com/code") - Visit the tree view for a deeply nested resource (e.g.
https://example.com/code/group-name/project-name/-/tree/v1.0.0/path/to/directory) - Near the top of the page, see the breadcrumb links (e.g.
project-name / path / to / directory) - Right-click on the the last breadcrumb link (e.g.
directory) and choose "Copy Link Address" (or equivalent, depending on your browser) - See that the URL is missing the path as configured in the
external_url(e.g. the URL ishttps://example.com/group-name/project-name/-/tree/v1.0.0/path/to/directorywhile it should behttps://example.com/code/group-name/project-name/-/tree/v1.0.0/path/to/directory- it is missing/code/at the start of the path)
This is a subtle bug because if you click on the breadcrumb links, client-side navigation works as expected. Although client-side navigation works, the issue is that the URL for the breadcrumb links is incorrect, so it will likely result in a 404 for anyone that copies it or anything that might follow it without clicking.
The bug is also subtle because breadcrumb links are correct for blob views (for example, the breadcrumb navigation for https://example.com/code/group-name/project-name/-/blob/v1.0.0/path/to/directory/file is correct). I've only seen the issue for tree views (but it may exist on other views).
Example Project
We have a private GitLab install that demonstrates this issue. I will try to gather more information on the version of GitLab that is running there.
What is the current bug behavior?
The breadcrumb links for tree views are incorrect, leading to 404s for anyone that copies the URL or automatically follows the links (without clicking).
What is the expected correct behavior?
I would expect the breadcrumb links for tree views to include the correct path in the URL.
Relevant logs and/or screenshots
Proposed fix
In new header app
It doesn't look like it's fixed in the new header though, to fix it I think we'll need to check that
project_short_pathandproject_pathis correctly passed from tree_helper.rb#L148-169 so that the breadcrumbs component can use it to build the correct links.
