-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): fix mismatching on regex route path (#433)
- Loading branch information
1 parent
db21dd8
commit 0b57f13
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/client/src/components/pages/__test__/routePathItem.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { RouteRecordNormalized } from 'vue-router' | ||
import { mount } from '@vue/test-utils' | ||
import RoutePathItem from '../RoutePathItem.vue' | ||
|
||
describe('component: RoutePathItem', () => { | ||
it('parseExpressRoute can correctly split the route string', () => { | ||
const component = mount(RoutePathItem, { | ||
props: { | ||
route: { | ||
path: '/hey/', | ||
name: 'heya', | ||
} as RouteRecordNormalized, | ||
}, | ||
}) | ||
const parseExpressRoute = (component.vm as any).parseExpressRoute | ||
expect(parseExpressRoute('/foo/:id(\\d+)/bar')).toEqual(['/foo/', ':id(\\d+)', '/bar']) | ||
expect(parseExpressRoute('/foo/:id*')).toEqual(['/foo/', ':id*']) | ||
expect(parseExpressRoute('/foo/:id+')).toEqual(['/foo/', ':id+']) | ||
expect(parseExpressRoute('/foo/:id/bar')).toEqual(['/foo/', ':id', '/bar']) | ||
expect(parseExpressRoute('/foo/:id')).toEqual(['/foo/', ':id']) | ||
expect(parseExpressRoute('/:id(\\d+)+')).toEqual(['/', ':id(\\d+)+']) | ||
expect(parseExpressRoute('/:id(\\d+)*')).toEqual(['/', ':id(\\d+)*']) | ||
expect(parseExpressRoute('/:id(\\d+)*/:name+')).toEqual(['/', ':id(\\d+)*', '/', ':name+']) | ||
// Example from Vue Router documentation | ||
// https://router.vuejs.org/guide/essentials/dynamic-matching.html#Catch-all-404-Not-found-Route | ||
expect(parseExpressRoute('/foo-:bar(.*)')).toEqual(['/foo-', ':bar(.*)']) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters