fix: handle URLs wrapped in parentheses

This commit is contained in:
codytseng 2026-01-07 14:56:00 +08:00
parent e369e2b93f
commit d7eac362f8

View file

@ -90,7 +90,17 @@ export const EmbeddedUrlParser: TContentParser = (content: string) => {
}) })
} }
const url = match[0] let url = match[0]
if (url.endsWith(')')) {
// Handle case where URL is wrapped in parentheses
const openParens = (url.match(/\(/g) || []).length
const closeParens = (url.match(/\)/g) || []).length
if (closeParens > openParens) {
// More closing parens than opening, likely the last char is not part of URL
url = url.slice(0, -1)
}
}
let type: TEmbeddedNodeType = 'url' let type: TEmbeddedNodeType = 'url'
if (isImage(url)) { if (isImage(url)) {
type = 'image' type = 'image'