Commit 179e4512 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'ph/encodeUriComponentNewDirectoryPath' into 'master'

Fix new file not being created in non-ascii character folders

See merge request gitlab-org/gitlab!26165
parents 542f6552 68aacde6
...@@ -134,7 +134,9 @@ export default { ...@@ -134,7 +134,9 @@ export default {
}, },
{ {
attrs: { attrs: {
href: `${this.newBlobPath}/${this.currentPath ? escape(this.currentPath) : ''}`, href: `${this.newBlobPath}/${
this.currentPath ? encodeURIComponent(this.currentPath) : ''
}`,
class: 'qa-new-file-option', class: 'qa-new-file-option',
}, },
text: __('New file'), text: __('New file'),
......
...@@ -25,10 +25,10 @@ export default { ...@@ -25,10 +25,10 @@ export default {
const splitArray = this.path.split('/'); const splitArray = this.path.split('/');
splitArray.pop(); splitArray.pop();
return splitArray.join('/'); return splitArray.map(p => encodeURIComponent(p)).join('/');
}, },
parentRoute() { parentRoute() {
return { path: `/-/tree/${escape(this.commitRef)}/${escape(this.parentPath)}` }; return { path: `/-/tree/${escape(this.commitRef)}/${this.parentPath}` };
}, },
}, },
methods: { methods: {
......
---
title: Fix new file not being created in non-ascii character folders
merge_request: 26165
author:
type: fixed
...@@ -31,10 +31,11 @@ describe('Repository parent row component', () => { ...@@ -31,10 +31,11 @@ describe('Repository parent row component', () => {
}); });
it.each` it.each`
path | to path | to
${'app'} | ${'/-/tree/master/'} ${'app'} | ${'/-/tree/master/'}
${'app/assets'} | ${'/-/tree/master/app'} ${'app/assets'} | ${'/-/tree/master/app'}
${'app/assets#/test'} | ${'/-/tree/master/app/assets%23'} ${'app/assets#/test'} | ${'/-/tree/master/app/assets%23'}
${'app/assets#/test/world'} | ${'/-/tree/master/app/assets%23/test'}
`('renders link in $path to $to', ({ path, to }) => { `('renders link in $path to $to', ({ path, to }) => {
factory(path); factory(path);
......
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