mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 Fixed 404 handling in admin
refs https://github.com/TryGhost/Ghost/issues/9571 - use `replaceWith` rather than `transitionTo` so that the back button still works and doesn't immediately throw you back to the 404 page - use the new `router` service to avoid deprecation notices - update the regex replacements to work with `#` urls
This commit is contained in:
parent
8dd8257bf7
commit
8ed92dec71
1 changed files with 10 additions and 2 deletions
|
@ -38,6 +38,9 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, {
|
||||||
settings: service(),
|
settings: service(),
|
||||||
tour: service(),
|
tour: service(),
|
||||||
ui: service(),
|
ui: service(),
|
||||||
|
// TODO: rename to `router` when we drop using of Route#router in our
|
||||||
|
// document-title util
|
||||||
|
routerService: service('router'),
|
||||||
|
|
||||||
shortcuts,
|
shortcuts,
|
||||||
|
|
||||||
|
@ -194,14 +197,19 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, {
|
||||||
}
|
}
|
||||||
|
|
||||||
let routeInfo = transition.handlerInfos[transition.handlerInfos.length - 1];
|
let routeInfo = transition.handlerInfos[transition.handlerInfos.length - 1];
|
||||||
let router = this.get('router');
|
let router = this.get('routerService');
|
||||||
let params = [];
|
let params = [];
|
||||||
|
|
||||||
for (let key of Object.keys(routeInfo.params)) {
|
for (let key of Object.keys(routeInfo.params)) {
|
||||||
params.push(routeInfo.params[key]);
|
params.push(routeInfo.params[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.transitionTo('error404', router.generate(routeInfo.name, ...params).replace('/ghost/', '').replace(/^\//g, ''));
|
let url = router.urlFor(routeInfo.name, ...params)
|
||||||
|
.replace(/^#\//, '')
|
||||||
|
.replace(/^\//, '')
|
||||||
|
.replace(/^ghost\//, '');
|
||||||
|
|
||||||
|
return this.replaceWith('error404', url);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVersionMismatchError(error)) {
|
if (isVersionMismatchError(error)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue