diff --git a/modules/rules.ts b/modules/rules.ts index 657d6a1..7fe5d88 100644 --- a/modules/rules.ts +++ b/modules/rules.ts @@ -1,6 +1,6 @@ export const defaultOrConstrained = (match: string): string => '(' + - (match ? match.replace(/(^<|>$)/g, '') : "[a-zA-Z0-9-_.~%':|=+]+") + + (match ? match.replace(/(^<|>$)/g, '') : "[a-zA-Z0-9-_.~%':|=+\\*]+") + ')' export type RegExpFactory = (match: any) => RegExp diff --git a/test/main.js b/test/main.js index 66dabb7..fd223be 100644 --- a/test/main.js +++ b/test/main.js @@ -220,6 +220,14 @@ describe('Path', function() { should.not.exist(path.test('/users;id=Z12345')) }) + it('should match and build paths with star (*) as a parameter value', function() { + const path = new Path('/test/:param') + + path.build({ param: 'super*' }).should.equal('/test/super*') + + path.test('/test/super*').should.eql({ param: 'super*' }) + }) + it('should match paths with optional trailing slashes', function() { let path = new Path('/my-path') should.not.exist(path.test('/my-path/', { strictTrailingSlash: true }))