Skip to content

Commit 017363d

Browse files
committed
[fixed] default redirect path to '*'
closes #507
1 parent 3e6a131 commit 017363d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

modules/components/__tests__/Redirect-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ var Route = require('../Route');
1010

1111
describe('Redirect', function () {
1212

13+
it('defaults the path to "*"', function () {
14+
TestLocation.history = [ '/kljfsdlfkjsdf' ];
15+
16+
var div = document.createElement('div');
17+
var routes = [
18+
<Route path="/bar" handler={Bar}/>,
19+
<Redirect to="/bar"/>
20+
];
21+
22+
Router.run(routes, TestLocation, function (Handler) {
23+
var html = React.render(<Handler />, div);
24+
expect(div.innerHTML).toMatch(/Bar/);
25+
});
26+
});
27+
1328
describe('at the root of the config', function () {
1429
it('redirects', function () {
1530
TestLocation.history = [ '/foo' ];

modules/utils/createRoutesFromChildren.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function createRoute(element, parentRoute, namedRoutes) {
5757

5858
if (type === Redirect.type) {
5959
route.handler = createRedirectHandler(props.to, props.params, props.query);
60-
props.path = props.path || props.from;
60+
props.path = props.path || props.from || '*';
6161
} else {
6262
route.handler = props.handler;
6363
}

0 commit comments

Comments
 (0)