fix: normalize alternate tkmind publish links
This commit is contained in:
@@ -435,7 +435,12 @@ function rewritePublishedHtmlLinks(text, artifacts = []) {
|
|||||||
`https?:\\/\\/[^\\s)]+\\/(?:MindSpace\\/[^\\s/]+\\/)?public\\/${escapeRegExp(filename)}\\b`,
|
`https?:\\/\\/[^\\s)]+\\/(?:MindSpace\\/[^\\s/]+\\/)?public\\/${escapeRegExp(filename)}\\b`,
|
||||||
'g',
|
'g',
|
||||||
);
|
);
|
||||||
|
const wrongTkmindHtmlLinkPattern = new RegExp(
|
||||||
|
`https?:\\/\\/(?:[^\\s./]+\\.)*tkmind\\.cn\\/[^\n\\s)]*${escapeRegExp(filename)}\\b`,
|
||||||
|
'gi',
|
||||||
|
);
|
||||||
next = next.replace(wrongPublicLinkPattern, canonicalUrl);
|
next = next.replace(wrongPublicLinkPattern, canonicalUrl);
|
||||||
|
next = next.replace(wrongTkmindHtmlLinkPattern, canonicalUrl);
|
||||||
next = next.replace(PUBLIC_HTML_LINK_PATTERN, (match) => {
|
next = next.replace(PUBLIC_HTML_LINK_PATTERN, (match) => {
|
||||||
if (match === canonicalUrl) return match;
|
if (match === canonicalUrl) return match;
|
||||||
const matchedFilename = String(match).split('/').pop();
|
const matchedFilename = String(match).split('/').pop();
|
||||||
|
|||||||
@@ -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, '<!doctype html><title>Prod Check</title>');
|
||||||
|
|
||||||
|
const text = await maybeAttachPublishedHtmlLink(
|
||||||
|
{
|
||||||
|
text: '唯一可访问链接:https://mindspace.tkmind.cn/a70ff537-8908-486e-9b6c-042e07cc25db/codex-prod-check-v6.html',
|
||||||
|
messages: [
|
||||||
|
{
|
||||||
|
role: 'assistant',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'toolRequest',
|
||||||
|
toolCall: {
|
||||||
|
value: {
|
||||||
|
name: 'sandbox-fs__write_file',
|
||||||
|
arguments: {
|
||||||
|
path: 'public/codex-prod-check-v6.html',
|
||||||
|
content: '<!doctype html><title>Prod Check</title>',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
workingDir: workspaceRoot,
|
||||||
|
publicBaseUrl: 'https://m.tkmind.cn',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.doesNotMatch(text, /https:\/\/mindspace\.tkmind\.cn\/.+\/codex-prod-check-v6\.html/);
|
||||||
|
assert.match(
|
||||||
|
text,
|
||||||
|
/https:\/\/m\.tkmind\.cn\/MindSpace\/.+\/public\/codex-prod-check-v6\.html/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('wechat mp service splits long agent replies into multiple customer messages', async () => {
|
test('wechat mp service splits long agent replies into multiple customer messages', async () => {
|
||||||
const token = 'token';
|
const token = 'token';
|
||||||
const timestamp = '1710000000';
|
const timestamp = '1710000000';
|
||||||
|
|||||||
Reference in New Issue
Block a user