fix(mindspace): link inline public html paths
This commit is contained in:
@@ -247,6 +247,28 @@ test('sanitizePublicHtmlLinksInText leaves other users missing-MindSpace links u
|
||||
assert.equal(next, text);
|
||||
});
|
||||
|
||||
test('sanitizePublicHtmlLinksInText links existing inline public html paths', () => {
|
||||
const owner = `test-user-${Date.now()}-inline-public-path`;
|
||||
const previousBase = process.env.H5_PUBLIC_BASE_URL;
|
||||
process.env.H5_PUBLIC_BASE_URL = 'https://m.tkmind.cn';
|
||||
const htmlPath = path.join(process.cwd(), 'MindSpace', owner, 'public', 'thailand-travel-guide.html');
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(htmlPath), { recursive: true });
|
||||
fs.writeFileSync(htmlPath, '<!doctype html><title>Thailand</title>');
|
||||
const text = '攻略页面已成功创建!文件位于 **`public/thailand-travel-guide.html`**(约 37KB)。';
|
||||
const next = sanitizePublicHtmlLinksInText(text, { id: owner, username: 'john2' });
|
||||
assert.doesNotMatch(next, /`public\/thailand-travel-guide\.html`/);
|
||||
assert.match(
|
||||
next,
|
||||
new RegExp(`\\[thailand-travel-guide\\.html\\]\\(https://m\\.tkmind\\.cn/MindSpace/${owner}/public/thailand-travel-guide\\.html\\)`),
|
||||
);
|
||||
} finally {
|
||||
if (previousBase == null) delete process.env.H5_PUBLIC_BASE_URL;
|
||||
else process.env.H5_PUBLIC_BASE_URL = previousBase;
|
||||
fs.rmSync(path.join(process.cwd(), 'MindSpace', owner), { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('sanitizeSessionConversationPublicHtmlLinks updates text items inside conversation messages', () => {
|
||||
const owner = `test-user-${Date.now()}-conversation`;
|
||||
const publicRoot = path.join(process.cwd(), 'MindSpace', owner, 'public');
|
||||
|
||||
Reference in New Issue
Block a user