Commit 96d9da9e authored by Phil Hughes's avatar Phil Hughes

Fixed Vue file browser not working with special characters

Closes https://gitlab.com/gitlab-org/gitlab/issues/199308
parent 3b9944fc
...@@ -107,10 +107,16 @@ export default { ...@@ -107,10 +107,16 @@ export default {
return acc.concat({ return acc.concat({
name, name,
path, path,
to: `/-/tree/${this.ref}${path}`, to: `/-/tree/${escape(this.ref)}${path}`,
}); });
}, },
[{ name: this.projectShortPath, path: '/', to: `/-/tree/${this.ref}/` }], [
{
name: this.projectShortPath,
path: '/',
to: `/-/tree/${escape(this.ref)}/`,
},
],
); );
}, },
canCreateMrFromFork() { canCreateMrFromFork() {
......
...@@ -28,7 +28,7 @@ export default { ...@@ -28,7 +28,7 @@ export default {
return splitArray.join('/'); return splitArray.join('/');
}, },
parentRoute() { parentRoute() {
return { path: `/-/tree/${this.commitRef}/${this.parentPath}` }; return { path: `/-/tree/${escape(this.commitRef)}/${this.parentPath}` };
}, },
}, },
methods: { methods: {
......
...@@ -90,7 +90,7 @@ export default { ...@@ -90,7 +90,7 @@ export default {
}, },
computed: { computed: {
routerLinkTo() { routerLinkTo() {
return this.isFolder ? { path: `/-/tree/${this.ref}/${this.path}` } : null; return this.isFolder ? { path: `/-/tree/${escape(this.ref)}/${this.path}` } : null;
}, },
iconName() { iconName() {
return `fa-${getIconName(this.type, this.path)}`; return `fa-${getIconName(this.type, this.path)}`;
......
...@@ -27,7 +27,10 @@ export function fetchLogsTree(client, path, offset, resolver = null) { ...@@ -27,7 +27,10 @@ export function fetchLogsTree(client, path, offset, resolver = null) {
fetchpromise = axios fetchpromise = axios
.get( .get(
`${gon.relative_url_root}/${projectPath}/-/refs/${ref}/logs_tree/${path.replace(/^\//, '')}`, `${gon.relative_url_root}/${projectPath}/-/refs/${escape(ref)}/logs_tree/${path.replace(
/^\//,
'',
)}`,
{ {
params: { format: 'json', offset }, params: { format: 'json', offset },
}, },
......
...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) { ...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) {
base: joinPaths(gon.relative_url_root || '', base), base: joinPaths(gon.relative_url_root || '', base),
routes: [ routes: [
{ {
path: `/-/tree/${baseRef}(/.*)?`, path: `/-/tree/${escape(baseRef)}(/.*)?`,
name: 'treePath', name: 'treePath',
component: TreePage, component: TreePage,
props: route => ({ props: route => ({
......
...@@ -171,6 +171,31 @@ describe "User browses files" do ...@@ -171,6 +171,31 @@ describe "User browses files" do
end end
end end
context "when browsing a `improve/awesome` branch", :js do
before do
visit(project_tree_path(project, "improve/awesome"))
end
it "shows files from a repository" do
expect(page).to have_content("VERSION")
.and have_content(".gitignore")
.and have_content("LICENSE")
end
end
context "when browsing a `test-#` branch", :js do
before do
project.repository.create_branch('test-#', project.repository.root_ref)
visit(project_tree_path(project, "test-#"))
end
it "shows files from a repository" do
expect(page).to have_content("VERSION")
.and have_content(".gitignore")
.and have_content("LICENSE")
end
end
context "when browsing a specific ref", :js do context "when browsing a specific ref", :js do
let(:ref) { project_tree_path(project, "6d39438") } let(:ref) { project_tree_path(project, "6d39438") }
......
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