updated htmlLinkRegex to allow for optional attributes in anchor tags

This commit is contained in:
dylan 2025-12-25 18:07:09 +00:00
parent e99989c268
commit ceaa7f6f89

View file

@ -10,8 +10,9 @@ export function markdownLinkRegex(url) {
}
export function htmlLinkRegex(url) {
const escapedUrl = url.replaceAll('.', '\\.')
return new RegExp(
`(<a [^>]*href="https:\\/\\/${url.replaceAll('.', '\\.')}[^"]*"[^>]*>).*?(<\\/a>)`,
`(<a[^>]+href=["']https?:\\/\\/${escapedUrl}[^"']*["'][^>]*>).*?(<\\/a>)`,
'i',
)
}