Skip to content

Commit

Permalink
Merge pull request troch#25 from faergeek/allow-star-as-a-param-value
Browse files Browse the repository at this point in the history
Allow star as a param value
  • Loading branch information
troch authored Jun 19, 2018
2 parents a438585 + 14bb91c commit 857b5db
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 857b5db

Please sign in to comment.