Skip to content

Commit

Permalink
Fix canonical url
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Sep 14, 2023
1 parent f347a3f commit 7746a66
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/codeforafrica/src/lib/data/seo.js
Original file line number Diff line number Diff line change
@@ -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 "";
Expand All @@ -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,
Expand Down

0 comments on commit 7746a66

Please sign in to comment.