Skip to content

Commit

Permalink
[fixed] default redirect path to '*'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Nov 24, 2014
1 parent 3e6a131 commit 017363d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions modules/components/__tests__/Redirect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ var Route = require('../Route');

describe('Redirect', function () {

it('defaults the path to "*"', function () {
TestLocation.history = [ '/kljfsdlfkjsdf' ];

var div = document.createElement('div');
var routes = [
<Route path="/bar" handler={Bar}/>,
<Redirect to="/bar"/>
];

Router.run(routes, TestLocation, function (Handler) {
var html = React.render(<Handler />, div);
expect(div.innerHTML).toMatch(/Bar/);
});
});

describe('at the root of the config', function () {
it('redirects', function () {
TestLocation.history = [ '/foo' ];
Expand Down
2 changes: 1 addition & 1 deletion modules/utils/createRoutesFromChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function createRoute(element, parentRoute, namedRoutes) {

if (type === Redirect.type) {
route.handler = createRedirectHandler(props.to, props.params, props.query);
props.path = props.path || props.from;
props.path = props.path || props.from || '*';
} else {
route.handler = props.handler;
}
Expand Down

0 comments on commit 017363d

Please sign in to comment.