Skip to content

Commit

Permalink
Merge pull request #18267 from ryanolsonx/bugfix/router-url-crash
Browse files Browse the repository at this point in the history
[BUGFIX beta] Router#url should not error when `location` is a string
  • Loading branch information
rwjblue authored Aug 16, 2019
2 parents 49973bc + 68f9114 commit 41a8d31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/@ember/-internals/routing/lib/system/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,13 @@ EmberRouter.reopen(Evented, {
@private
*/
url: computed(function(this: Router<Route>) {
return get(this, 'location').getURL();
let location = get(this, 'location');

if (typeof location === 'string') {
return undefined;
}

return location.getURL();
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,10 @@ moduleFor(
router.transitionTo('./route-b/1');
}, "A transition was attempted from 'route-a' to './route-b/1' but the application instance has already been destroyed.");
}

['@test computed url when location is a string should not crash'](assert) {
let router = createRouter(undefined, { disableSetup: true });
assert.equal(router.url, undefined);
}
}
);

0 comments on commit 41a8d31

Please sign in to comment.