])
})
+ it('escapes {', () => {
+ expect(tokenizePath('/\\{')).toEqual([
+ [{ type: TokenType.Static, value: '{' }],
+ ])
+ })
+
+ // TODO: add test when groups exist
+ it.skip('escapes } inside group', () => {
+ expect(tokenizePath('/{\\{}')).toEqual([
+ [{ type: TokenType.Static, value: '{' }],
+ ])
+ })
+
it('escapes ( inside custom re', () => {
expect(tokenizePath('/:a(\\))')).toEqual([
[
})
})
+ // TODO: better syntax? like /a/{b-:param}+
+ // also to allow repeatable because otherwise groups are meaningless
+ it('group', () => {
+ matchParams('/a/:a(?:b-([^/]+\\)?)', '/a/b-one', {
+ a: 'one',
+ })
+ })
+
it('catch all', () => {
matchParams('/:rest(.*)', '/a/b/c', { rest: 'a/b/c' })
matchParams('/:rest(.*)/no', '/a/b/c/no', { rest: 'a/b/c' })
matchStringify('/:id', { id: 'one' }, '/one')
})
+ it('params with custom regexp', () => {
+ matchStringify('/:id(\\d+)-:w(\\w+)', { id: '2', w: 'hey' }, '/2-hey')
+ })
+
it('multiple param one segment', () => {
matchStringify('/:a-:b', { a: 'one', b: 'two' }, '/one-two')
})