Skip to content

Commit 1310feb

Browse files
committed
Throw when <Redirect to> is relative
1 parent 63f1be5 commit 1310feb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

modules/Redirect.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ var Redirect = React.createClass({
2323
if (route.from)
2424
route.path = route.from;
2525

26+
// TODO: Handle relative pathnames, see #1658
27+
invariant(
28+
route.to.charAt(0) === '/',
29+
'<Redirect to> must be an absolute path. This should be fixed in the future'
30+
);
31+
2632
route.onEnter = function (nextState, redirectTo) {
2733
var { location, params } = nextState;
28-
29-
// TODO: Handle relative pathnames.
3034
var pathname = route.to ? formatPattern(route.to, params) : location.pathname;
3135

3236
redirectTo(

0 commit comments

Comments
 (0)