Commit 1a56ac66 authored by Phil Hughes's avatar Phil Hughes

Decode URI before passing to Vue Router for file listing router

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/217444
parent b7e94f0a
......@@ -7,17 +7,28 @@ import TreePage from './pages/tree.vue';
Vue.use(VueRouter);
export default function createRouter(base, baseRef) {
const treePathRoute = {
component: TreePage,
props: route => ({
path: route.params.path?.replace(/^\//, '') || '/',
}),
};
return new VueRouter({
mode: 'history',
base: joinPaths(gon.relative_url_root || '', base),
routes: [
{
path: `(/-)?/tree/${baseRef}/:path*`,
name: 'treePathDecoded',
// Sometimes the ref needs decoding depending on how the backend sends it to us
path: `(/-)?/tree/${decodeURI(baseRef)}/:path*`,
...treePathRoute,
},
{
name: 'treePath',
component: TreePage,
props: route => ({
path: route.params.path?.replace(/^\//, '') || '/',
}),
// Support without decoding as well just in case the ref doesn't need to be decoded
path: `(/-)?/tree/${baseRef}/:path*`,
...treePathRoute,
},
{
path: '/',
......
......@@ -209,6 +209,33 @@ describe "User browses files" do
end
end
context "when browsing a `Ääh-test-utf-8` branch", :js do
before do
project.repository.create_branch('Ääh-test-utf-8', project.repository.root_ref)
visit(project_tree_path(project, "Ääh-test-utf-8"))
end
it "shows files from a repository" 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
context "when browsing a `test-#` branch", :js do
before do
project.repository.create_branch('test-#', project.repository.root_ref)
......
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