Skip to content

Commit

Permalink
[fixed] transitioning to paths with .
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Oct 7, 2014
1 parent ec2d7a9 commit 668773c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/utils/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ function encodeURLPath(path) {
return String(path).split('/').map(encodeURL).join('/');
}

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

var _compiledPatterns = {};

function compilePattern(pattern) {
if (!(pattern in _compiledPatterns)) {
var paramNames = [];
var source = pattern.replace(paramMatcher, function (match, paramName) {
var source = pattern.replace(paramCompileMatcher, function (match, paramName) {
if (paramName) {
paramNames.push(paramName);
return '([^/?#]+)';
Expand Down Expand Up @@ -82,7 +83,7 @@ var Path = {

var splatIndex = 0;

return pattern.replace(paramMatcher, function (match, paramName) {
return pattern.replace(paramInjectMatcher, function (match, paramName) {
paramName = paramName || 'splat';

invariant(
Expand Down
6 changes: 6 additions & 0 deletions modules/utils/__tests__/Path-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ describe('Path.injectParams', function () {
}).toThrow(Error);
});
});

describe('when a pattern has dots', function() {
it('returns the correct path', function() {
expect(Path.injectParams('/foo.bar.baz')).toEqual('/foo.bar.baz');
});
});
});

describe('Path.extractQuery', function () {
Expand Down

0 comments on commit 668773c

Please sign in to comment.