From 616f8bf955d011d0a33a7697bd2880ce465a33f3 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 16 Jul 2014 22:41:41 -0700 Subject: [PATCH] [changed] Preserve forward slashes in URL params This is helpful when using * to match fs-like paths. --- modules/helpers/Path.js | 3 ++- specs/Path.spec.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/helpers/Path.js b/modules/helpers/Path.js index 114bc200c6..0fa709736e 100644 --- a/modules/helpers/Path.js +++ b/modules/helpers/Path.js @@ -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('/'); }); }, diff --git a/specs/Path.spec.js b/specs/Path.spec.js index 9bbf226274..b0cf65378d 100644 --- a/specs/Path.spec.js +++ b/specs/Path.spec.js @@ -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'); + }); + }); }); });