diff --git a/scripts/patch-micropub-swarm-loc-guard.mjs b/scripts/patch-micropub-swarm-loc-guard.mjs index 7ee7822d..6d5cc520 100644 --- a/scripts/patch-micropub-swarm-loc-guard.mjs +++ b/scripts/patch-micropub-swarm-loc-guard.mjs @@ -29,11 +29,18 @@ const newSnippet = ` if ( (hasCheckinProperty || hasSwarmSyndication) ) { // Guard: only accept OwnYourSwarm posts that contain "Loc" in content. ${MARKER} - const rawContent = Array.isArray(properties.content) - ? properties.content.join(" ") - : String(properties.content || ""); + // Extract raw text before normaliseProperties converts content to {html,text} object. + // After normalisation, String(properties.content) yields "[object Object]" — not useful. + // We read .text/.html from the normalised object, then fall back to raw string. + const rawContent = (() => { + const c = properties.content; + if (!c) return ""; + if (typeof c === "string") return c; + if (typeof c === "object") return String(c.text || c.html || ""); + return String(c); + })(); if (hasSwarmSyndication && !rawContent.includes("Loc")) { - throw new IndiekitError(422, "OwnYourSwarm post without 'Loc' in content rejected"); + throw new IndiekitError("OwnYourSwarm post without 'Loc' in content rejected", { status: 422, code: "invalid_request" }); } properties.visibility = "unlisted"; }`;