Skip to content

Commit

Permalink
add decodeURIComponent, decodeURI does not always catch the path when…
Browse files Browse the repository at this point in the history
… decoding with test
  • Loading branch information
ekristen committed Apr 22, 2015
1 parent 8ceaa1c commit a503730
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -23,6 +23,7 @@ function regify(vurl) {

function paramify(url) {
try { url = decodeURI(url) } catch($) {}
try { url = decodeURIComponent(url) } catch($) {}

function match (vurl) {

Expand Down
11 changes: 10 additions & 1 deletion test/paramify.js
Expand Up @@ -49,4 +49,13 @@ test('regex fail to match', function (t) {

match = paramify('/@username')
t.assert(!match(/^\/(xprofile|@#(.*?))/))
})
})

test('encoded paths', function(t) {
t.plan(3)

var match = paramify('/@example%2ftest')
t.assert(match('/@:first/:second'))
t.equal(match.params.first, 'example')
t.equal(match.params.second, 'test')
})

0 comments on commit a503730

Please sign in to comment.