Skip to content

Commit

Permalink
feat: allow star as a param value
Browse files Browse the repository at this point in the history
  • Loading branch information
faergeek committed Jun 15, 2018
1 parent a438585 commit 14bb91c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/rules.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
Expand Down

0 comments on commit 14bb91c

Please sign in to comment.