diff --git a/apps/codeforafrica/src/lib/data/seo.js b/apps/codeforafrica/src/lib/data/seo.js index e4c793925..d6ca6cd5a 100644 --- a/apps/codeforafrica/src/lib/data/seo.js +++ b/apps/codeforafrica/src/lib/data/seo.js @@ -1,5 +1,6 @@ import site from "@/codeforafrica/utils/site"; +const siteUrl = new URL(site.environmentUrl).href; function stringifyDescription(description) { if (!description || !Array.isArray(description)) { return ""; @@ -26,7 +27,10 @@ export default function getPageSeoFromMeta(page, settings) { metaDescription || stringifyDescription(siteDescription) || null; const titleTemplate = siteTitle ? `%s | ${siteTitle}` : null; const defaultTitle = siteTitle || null; - const canonical = site.url; + // TODO: Handle canonical url for nested pages + // NOTE: We can do this Regex because we're sure about the url contents + // see: https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS + const canonical = siteUrl.replace(/\/+$/, ""); const openGraph = { title, description,