Skip to content

Commit f975bdf

Browse files
committed
[fixed] allow a StaticLocation to be passed directly when creating a router
1 parent 7d52d55 commit f975bdf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/createRouter.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@ function createRouter(options) {
134134
var pendingTransition = null;
135135
var dispatchHandler = null;
136136

137-
if (typeof location === 'string') {
137+
if (typeof location === 'string')
138+
location = new StaticLocation(location);
139+
140+
if (location instanceof StaticLocation) {
138141
warning(
139142
!canUseDOM || process.env.NODE_ENV === 'test',
140143
'You should not use a static location in a DOM environment because ' +
141144
'the router will not be kept in sync with the current URL'
142145
);
143-
144-
location = new StaticLocation(location);
145146
} else {
146147
invariant(
147148
canUseDOM || location.needsDOM === false,

0 commit comments

Comments
 (0)