Commit 983df442 authored by Phil Hughes's avatar Phil Hughes

Fixed repository browser not working for branches with parentheses

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/212785
parent 72fc66f6
import Vue from 'vue'; import Vue from 'vue';
import VueRouter from 'vue-router'; import VueRouter from 'vue-router';
import { escapeRegExp } from 'lodash';
import { joinPaths } from '../lib/utils/url_utility'; import { joinPaths } from '../lib/utils/url_utility';
import IndexPage from './pages/index.vue'; import IndexPage from './pages/index.vue';
import TreePage from './pages/tree.vue'; import TreePage from './pages/tree.vue';
...@@ -27,7 +28,7 @@ export default function createRouter(base, baseRef) { ...@@ -27,7 +28,7 @@ export default function createRouter(base, baseRef) {
{ {
name: 'treePath', name: 'treePath',
// Support without decoding as well just in case the ref doesn't need to be decoded // Support without decoding as well just in case the ref doesn't need to be decoded
path: `(/-)?/tree/${baseRef}/:path*`, path: `(/-)?/tree/${escapeRegExp(baseRef)}/:path*`,
...treePathRoute, ...treePathRoute,
}, },
{ {
......
---
title: Fixed repository browser not working with parentheses in branch name
merge_request: 41591
author:
type: fixed
...@@ -4,12 +4,13 @@ import createRouter from '~/repository/router'; ...@@ -4,12 +4,13 @@ import createRouter from '~/repository/router';
describe('Repository router spec', () => { describe('Repository router spec', () => {
it.each` it.each`
path | branch | component | componentName path | branch | component | componentName
${'/'} | ${'master'} | ${IndexPage} | ${'IndexPage'} ${'/'} | ${'master'} | ${IndexPage} | ${'IndexPage'}
${'/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'} ${'/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'} ${'/tree/feat(test)'} | ${'feat(test)'} | ${TreePage} | ${'TreePage'}
${'/-/tree/master/app/assets'} | ${'master'} | ${TreePage} | ${'TreePage'} ${'/-/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/123/app/assets'} | ${'master'} | ${null} | ${'null'} ${'/-/tree/master/app/assets'} | ${'master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/123/app/assets'} | ${'master'} | ${null} | ${'null'}
`('sets component as $componentName for path "$path"', ({ path, component, branch }) => { `('sets component as $componentName for path "$path"', ({ path, component, branch }) => {
const router = createRouter('', branch); const router = createRouter('', branch);
......
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