mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Moved route checking logic closer to the origin
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events - The URL Service should not be filled with preventative logic and know about internal methods of the routers (e.g. getPermalinks). Because it's only called through a single place the logic can now live in the routing package and not leak outside it
This commit is contained in:
parent
048b1102ad
commit
ced6119fc1
2 changed files with 6 additions and 7 deletions
6
core/frontend/services/routing/bootstrap.js
vendored
6
core/frontend/services/routing/bootstrap.js
vendored
|
@ -168,6 +168,12 @@ module.exports.internal = {
|
|||
// and should not be consumed by the modules outside the frontend
|
||||
events.emit('router.created', this);
|
||||
|
||||
// CASE: there are router types which do not generate resource urls
|
||||
// e.g. static route router, in this case we don't want ot notify the URL service
|
||||
if (!router || !router.getPermalinks()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_urlService.onRouterAddedType(router);
|
||||
},
|
||||
routerUpdated: (router) => {
|
||||
|
|
|
@ -76,13 +76,6 @@ class UrlService {
|
|||
* @param {ExpressRouter} router
|
||||
*/
|
||||
onRouterAddedType(router) {
|
||||
// CASE: there are router types which do not generate resource urls
|
||||
// e.g. static route router
|
||||
// we are listening on the general `router.created` event - every router throws this event
|
||||
if (!router || !router.getPermalinks()) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug('Registering route: ', router.name);
|
||||
|
||||
let urlGenerator = new UrlGenerator(router, this.queue, this.resources, this.urls, this.urlGenerators.length);
|
||||
|
|
Loading…
Add table
Reference in a new issue