From b35b1ae98becf9c161d2130a8311e217a1d077d2 Mon Sep 17 00:00:00 2001 From: Naz Date: Fri, 3 Feb 2023 13:11:49 +0800 Subject: [PATCH] Added cleanup note refs https://github.com/TryGhost/Toolbox/issues/516 refs https://github.com/TryGhost/Ghost/commit/4c60cdce9c5c66d0477b247b8b5bbdb46e7aba71 - The syntax used to skip non-`/r/` routes is unreadable. Needs a little love during cleanup --- ghost/link-redirects/lib/LinkRedirectsService.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ghost/link-redirects/lib/LinkRedirectsService.js b/ghost/link-redirects/lib/LinkRedirectsService.js index 3b234c07c1..b5bbc4f952 100644 --- a/ghost/link-redirects/lib/LinkRedirectsService.js +++ b/ghost/link-redirects/lib/LinkRedirectsService.js @@ -87,6 +87,12 @@ class LinkRedirectsService { async handleRequest(req, res, next) { // skip handling if original url doesn't match the prefix const fullURLWithRedirectPrefix = `${this.#baseURL.pathname}${this.#redirectURLPrefix}`; + // @NOTE: below is equivalent to doing: + // router.get('/r/'), (req, res) ... + // To make it cleaner we should rework it to: + // linkRedirects.service.handleRequest(router); + // and mount routes on top like for example sitemapHandler does + // Cleanup issue: https://github.com/TryGhost/Toolbox/issues/516 if (!req.originalUrl.startsWith(fullURLWithRedirectPrefix)) { return next(); }