From 017363d6108dc3e85d095f8b062554b6a3c75d50 Mon Sep 17 00:00:00 2001 From: Ryan Florence Date: Mon, 24 Nov 2014 09:10:08 -0700 Subject: [PATCH] [fixed] default redirect path to '*' closes #507 --- modules/components/__tests__/Redirect-test.js | 15 +++++++++++++++ modules/utils/createRoutesFromChildren.js | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/components/__tests__/Redirect-test.js b/modules/components/__tests__/Redirect-test.js index b3031b02a7..0b7ad8d791 100644 --- a/modules/components/__tests__/Redirect-test.js +++ b/modules/components/__tests__/Redirect-test.js @@ -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 = [ + , + + ]; + + Router.run(routes, TestLocation, function (Handler) { + var html = React.render(, div); + expect(div.innerHTML).toMatch(/Bar/); + }); + }); + describe('at the root of the config', function () { it('redirects', function () { TestLocation.history = [ '/foo' ]; diff --git a/modules/utils/createRoutesFromChildren.js b/modules/utils/createRoutesFromChildren.js index bd9b8257af..2b515c5454 100644 --- a/modules/utils/createRoutesFromChildren.js +++ b/modules/utils/createRoutesFromChildren.js @@ -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; }