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!
This commit is contained in:
Fabien "egg" O'Carroll 2023-01-20 17:00:54 +07:00 committed by Fabien 'egg' O'Carroll
parent 5b4bc01504
commit 833182bc7f

View File

@ -45,7 +45,16 @@ module.exports = {
} }
}, },
routingService: { 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; return true;
} }
} }