Skip to content

Commit f86aeca

Browse files
committed
Merge pull request #937 from benjie/fix-empty-query-string
Empty query string ("/?") causes route match to fail
2 parents 105d21a + 59c28de commit f86aeca

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

modules/PathUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var qs = require('qs');
55
var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
66
var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
77
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g;
8-
var queryMatcher = /\?(.+)/;
8+
var queryMatcher = /\?(.*)$/;
99

1010
var _compiledPatterns = {};
1111

modules/__tests__/Router-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,15 @@ describe('Router', function () {
648648
});
649649
});
650650

651+
it('renders with empty query string', function (done) {
652+
var routes = <Route handler={Foo} path='/'/>;
653+
Router.run(routes, '/?', function (Handler, state) {
654+
var html = React.renderToString(<Handler />);
655+
expect(html).toMatch(/Foo/);
656+
done();
657+
});
658+
});
659+
651660
it('executes transition hooks when only the query changes', function (done) {
652661
var fromKnifeCalled = false;
653662
var fromSpoonCalled = false;

0 commit comments

Comments
 (0)