diff --git a/modules/utils/Path.js b/modules/utils/Path.js index c7fa96d11c..6641928596 100644 --- a/modules/utils/Path.js +++ b/modules/utils/Path.js @@ -4,7 +4,7 @@ var qs = require('qs'); var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g; var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g; -var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?/g; +var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g; var queryMatcher = /\?(.+)/; var _compiledPatterns = {}; diff --git a/modules/utils/__tests__/Path-test.js b/modules/utils/__tests__/Path-test.js index 842e80ce2e..92ba633afd 100644 --- a/modules/utils/__tests__/Path-test.js +++ b/modules/utils/__tests__/Path-test.js @@ -274,6 +274,12 @@ describe('Path.injectParams', function () { expect(Path.injectParams('/foo.bar.baz')).toEqual('/foo.bar.baz'); }); }); + + describe('when a pattern has optional slashes', function () { + it('returns the correct path', function () { + expect(Path.injectParams('/foo/?/bar/?/baz/?')).toEqual('/foo/bar/baz/'); + }); + }); }); describe('Path.extractQuery', function () {