diff --git a/wechat-mp.mjs b/wechat-mp.mjs index 6acfbd0..f90b81c 100644 --- a/wechat-mp.mjs +++ b/wechat-mp.mjs @@ -435,7 +435,12 @@ function rewritePublishedHtmlLinks(text, artifacts = []) { `https?:\\/\\/[^\\s)]+\\/(?:MindSpace\\/[^\\s/]+\\/)?public\\/${escapeRegExp(filename)}\\b`, 'g', ); + const wrongTkmindHtmlLinkPattern = new RegExp( + `https?:\\/\\/(?:[^\\s./]+\\.)*tkmind\\.cn\\/[^\n\\s)]*${escapeRegExp(filename)}\\b`, + 'gi', + ); next = next.replace(wrongPublicLinkPattern, canonicalUrl); + next = next.replace(wrongTkmindHtmlLinkPattern, canonicalUrl); next = next.replace(PUBLIC_HTML_LINK_PATTERN, (match) => { if (match === canonicalUrl) return match; const matchedFilename = String(match).split('/').pop(); diff --git a/wechat-mp.test.mjs b/wechat-mp.test.mjs index 14d4fcf..489e252 100644 --- a/wechat-mp.test.mjs +++ b/wechat-mp.test.mjs @@ -336,6 +336,48 @@ test('maybeAttachPublishedHtmlLink rewrites wrong public html links to the canon ); }); +test('maybeAttachPublishedHtmlLink rewrites tkmind domain variants to the canonical published url', async () => { + const workspaceRoot = fs.mkdtempSync('/tmp/wechat-mp-rewrite-domain-'); + const htmlPath = `${workspaceRoot}/public/codex-prod-check-v6.html`; + fs.mkdirSync(`${workspaceRoot}/public`, { recursive: true }); + fs.writeFileSync(htmlPath, '