Skip to content

Commit

Permalink
feat(UrlMatcher): support for URI-encoded values of query params
Browse files Browse the repository at this point in the history
Addresses #25
  • Loading branch information
kcrwfrd committed Jun 29, 2017
1 parent bf187bb commit dec0beb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/UrlMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UrlMatcher {
for (let item of queryPattern.split('&')) {
this.queryParams.push(item)

let queryPattern = `${item}=([\\w-]+)`
let queryPattern = `${item}=([\\w-.~:/?#[\\]@!$'"()*+,:%]+)`

this.queryPatterns.push(new RegExp(queryPattern))
}
Expand Down
9 changes: 9 additions & 0 deletions src/spec/UrlMatcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ describe('UrlMatcher:', () => {
bazId: null,
})
})

it('Should match a param value of a URI-encoded JSON blob.', () => {
let urlMatcher = new UrlMatcher('/?foo')
let value = '%7B%22test%22%3A%7B%22a%22%3A%5B%22hi%22%2Cnull%5D%7D%7D'

expect(urlMatcher.exec(`/?foo=${value}`)).toEqual({
foo: value
})
})
})
})
})

0 comments on commit dec0beb

Please sign in to comment.