Commit 60307f16 authored by Phil Hughes's avatar Phil Hughes

Fix directory paths incorrectly encoding URLs

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/209075
parent 3d13b601
<script> <script>
import { GlDropdown, GlDropdownDivider, GlDropdownHeader, GlDropdownItem } from '@gitlab/ui'; import { GlDropdown, GlDropdownDivider, GlDropdownHeader, GlDropdownItem } from '@gitlab/ui';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths, escapeFileUrl } from '~/lib/utils/url_utility';
import { __ } from '../../locale'; import { __ } from '../../locale';
import Icon from '../../vue_shared/components/icon.vue'; import Icon from '../../vue_shared/components/icon.vue';
import getRefMixin from '../mixins/get_ref'; import getRefMixin from '../mixins/get_ref';
...@@ -103,7 +103,7 @@ export default { ...@@ -103,7 +103,7 @@ export default {
.filter(p => p !== '') .filter(p => p !== '')
.reduce( .reduce(
(acc, name, i) => { (acc, name, i) => {
const path = joinPaths(i > 0 ? acc[i].path : '', encodeURIComponent(name)); const path = joinPaths(i > 0 ? acc[i].path : '', escapeFileUrl(name));
return acc.concat({ return acc.concat({
name, name,
......
<script> <script>
import { escapeRegExp } from 'lodash'; import { escapeRegExp } from 'lodash';
import { GlBadge, GlLink, GlSkeletonLoading, GlTooltipDirective, GlLoadingIcon } from '@gitlab/ui'; import { GlBadge, GlLink, GlSkeletonLoading, GlTooltipDirective, GlLoadingIcon } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl, escapeFileUrl } from '~/lib/utils/url_utility';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { getIconName } from '../../utils/icon'; import { getIconName } from '../../utils/icon';
...@@ -92,7 +92,7 @@ export default { ...@@ -92,7 +92,7 @@ export default {
computed: { computed: {
routerLinkTo() { routerLinkTo() {
return this.isFolder return this.isFolder
? { path: `/-/tree/${escape(this.ref)}/${encodeURIComponent(this.path)}` } ? { path: `/-/tree/${escape(this.ref)}/${escapeFileUrl(this.path)}` }
: null; : null;
}, },
iconName() { iconName() {
......
...@@ -4,7 +4,10 @@ import { visitUrl } from '~/lib/utils/url_utility'; ...@@ -4,7 +4,10 @@ import { visitUrl } from '~/lib/utils/url_utility';
import TableRow from '~/repository/components/table/row.vue'; import TableRow from '~/repository/components/table/row.vue';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
jest.mock('~/lib/utils/url_utility'); jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
visitUrl: jest.fn(),
}));
let vm; let vm;
let $router; let $router;
......
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