Skip to content

Commit

Permalink
[changed] Preserve forward slashes in URL params
Browse files Browse the repository at this point in the history
This is helpful when using * to match fs-like paths.
  • Loading branch information
mjackson committed Jul 17, 2014
1 parent 6c74c69 commit 616f8bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/helpers/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ var Path = {
'Missing "' + paramName + '" parameter for path "' + pattern + '"'
);

return URL.encode(params[paramName]);
// Preserve forward slashes.
return String(params[paramName]).split('/').map(URL.encode).join('/');
});
},

Expand Down
6 changes: 6 additions & 0 deletions specs/Path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ describe('Path.injectParams', function () {
expect(Path.injectParams(pattern, { id: 'one, two' })).toEqual('comments/one%2C+two/edit');
});
});

describe('and a param has a forward slash', function () {
it('preserves the forward slash', function () {
expect(Path.injectParams(pattern, { id: 'the/id' })).toEqual('comments/the/id/edit');
});
});
});
});

Expand Down

0 comments on commit 616f8bf

Please sign in to comment.