From b5a88d9746d133245a8acac1357138fcbbeff2c5 Mon Sep 17 00:00:00 2001
From: john
Date: Sat, 4 Jul 2026 14:15:42 +0800
Subject: [PATCH] fix(brand): require TKMind platform marker on wechat page
delivery
Backfill missing platform-brand footer at serve time and block service-
account links when the HTML file omits data-mindspace-page-tag.
Co-authored-by: Cursor
---
mindspace-page-tag.mjs | 18 ++++++++++++++++
mindspace-page-tag.test.mjs | 8 +++++++
mindspace-public-delivery.mjs | 2 ++
wechat-mp.test.mjs | 2 +-
wechat/handlers/page-generate.mjs | 12 ++++++++---
wechat/prompts/page-generate.mjs | 10 +++++++--
wechat/verify/share-preview.mjs | 6 ++++++
wechat/wechat-channel.test.mjs | 35 ++++++++++++++++++++++++-------
8 files changed, 79 insertions(+), 14 deletions(-)
diff --git a/mindspace-page-tag.mjs b/mindspace-page-tag.mjs
index c597dad..e3cc082 100644
--- a/mindspace-page-tag.mjs
+++ b/mindspace-page-tag.mjs
@@ -31,6 +31,24 @@ export function ensurePlatformBrandPageTags(html) {
});
}
+export function hasPlatformBrandMarker(html) {
+ return new RegExp(
+ `${MINDSPACE_PAGE_TAG_ATTR}\\s*=\\s*["']${MINDSPACE_PAGE_TAG_PLATFORM_BRAND}["']`,
+ 'i',
+ ).test(String(html ?? ''));
+}
+
+/** Append the platform brand footer when authors omitted data-mindspace-page-tag. */
+export function ensurePlatformBrandFooter(html) {
+ const normalized = ensurePlatformBrandPageTags(html);
+ if (hasPlatformBrandMarker(normalized)) return normalized;
+ const footer = `${PLATFORM_BRAND_TEXT}
`;
+ if (/<\/body>/i.test(normalized)) {
+ return normalized.replace(/<\/body>/i, `${footer}\n
content