From 833182bc7fb29ebc3e8a0f332d9e18001181491e Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Fri, 20 Jan 2023 17:00:54 +0700 Subject: [PATCH] Implemented a basic RoutingService for Mentions refs https://github.com/TryGhost/Team/issues/2466 This initial implementation just checks that we're on the right origin and subdomain, but should be extended to check if the URL actually resolves to a page hosted on the site! --- ghost/core/core/server/services/mentions/service.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ghost/core/core/server/services/mentions/service.js b/ghost/core/core/server/services/mentions/service.js index c455b1def6..157b1d018c 100644 --- a/ghost/core/core/server/services/mentions/service.js +++ b/ghost/core/core/server/services/mentions/service.js @@ -45,7 +45,16 @@ module.exports = { } }, routingService: { - async pageExists() { + async pageExists(url) { + const siteUrl = new URL(urlUtils.getSiteUrl()); + if (siteUrl.origin !== url.origin) { + return false; + } + const subdir = urlUtils.getSubdir(); + if (subdir && !url.pathname.startsWith(subdir)) { + return false; + } + return true; } }