Merge pull request #3353 from LooseLi/fix-file-cannot-work

fix:兼容 Notion 的旧 AWS 链接格式与新的 attachment 链接,避免 embed 链接被错误处理
This commit is contained in:
tangly1024
2025-05-22 14:31:41 +08:00
committed by GitHub

View File

@@ -139,11 +139,10 @@ function convertNotionBlocksToPost(id, blockMap, slice) {
// 如果是文件或嵌入式PDF需要重新加密签名
if (
(b?.value?.type === 'file' ||
b?.value?.type === 'pdf' ||
b?.value?.type === 'video' ||
b?.value?.type === 'audio') &&
b?.value?.properties?.source?.[0][0]
['file', 'pdf', 'video', 'audio'].includes(b?.value?.type) &&
b?.value?.properties?.source?.[0][0] &&
(b?.value?.properties?.source?.[0][0].indexOf('attachment') === 0 ||
b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0)
) {
const oldUrl = b?.value?.properties?.source?.[0][0]
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`