Commit 799b371e authored by Phil Hughes's avatar Phil Hughes Committed by André Luís

Fixes file browser with slashes in branch name

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/215062
parent b36406aa
......@@ -108,14 +108,14 @@ export default {
return acc.concat({
name,
path,
to: `/-/tree/${joinPaths(encodeURIComponent(this.ref), path)}`,
to: `/-/tree/${joinPaths(escapeFileUrl(this.ref), path)}`,
});
},
[
{
name: this.projectShortPath,
path: '/',
to: `/-/tree/${encodeURIComponent(this.ref)}/`,
to: `/-/tree/${escapeFileUrl(this.ref)}/`,
},
],
);
......
<script>
import { GlLoadingIcon } from '@gitlab/ui';
import { escapeFileUrl } from '~/lib/utils/url_utility';
export default {
components: {
......@@ -28,7 +29,7 @@ export default {
return splitArray.map(p => encodeURIComponent(p)).join('/');
},
parentRoute() {
return { path: `/-/tree/${encodeURIComponent(this.commitRef)}/${this.parentPath}` };
return { path: `/-/tree/${escapeFileUrl(this.commitRef)}/${this.parentPath}` };
},
},
methods: {
......
......@@ -99,7 +99,7 @@ export default {
computed: {
routerLinkTo() {
return this.isFolder
? { path: `/-/tree/${encodeURIComponent(this.ref)}/${escapeFileUrl(this.path)}` }
? { path: `/-/tree/${escapeFileUrl(this.ref)}/${escapeFileUrl(this.path)}` }
: null;
},
isFolder() {
......
......@@ -180,6 +180,20 @@ describe "User browses files" do
expect(page).to have_content("VERSION")
.and have_content(".gitignore")
.and have_content("LICENSE")
click_link("files")
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link("html")
page.within('.repo-breadcrumb') do
expect(page).to have_link('html')
end
expect(page).to have_link('500.html')
end
end
......@@ -193,6 +207,20 @@ describe "User browses files" do
expect(page).to have_content("VERSION")
.and have_content(".gitignore")
.and have_content("LICENSE")
click_link("files")
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link("html")
page.within('.repo-breadcrumb') do
expect(page).to have_link('html')
end
expect(page).to have_link('500.html')
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment