Skip to content

Commit 19c7bd7

Browse files
committed
Merge pull request #774 from kentor/master
[fixed] Double slash in href when parent route has optional trailing sla...
2 parents 32d24a5 + 5bcf653 commit 19c7bd7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

modules/utils/Path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var qs = require('qs');
44

55
var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
66
var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
7-
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?/g;
7+
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g;
88
var queryMatcher = /\?(.+)/;
99

1010
var _compiledPatterns = {};

modules/utils/__tests__/Path-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ describe('Path.injectParams', function () {
274274
expect(Path.injectParams('/foo.bar.baz')).toEqual('/foo.bar.baz');
275275
});
276276
});
277+
278+
describe('when a pattern has optional slashes', function () {
279+
it('returns the correct path', function () {
280+
expect(Path.injectParams('/foo/?/bar/?/baz/?')).toEqual('/foo/bar/baz/');
281+
});
282+
});
277283
});
278284

279285
describe('Path.extractQuery', function () {

0 commit comments

Comments
 (0)