fix(markdown): handle mailto: links without target="_blank" to allow email client to open

## Summary

When mailto: links are rendered in chat responses, clicking them does not open the email client because the Link component adds target="_blank" to all valid URLs including mailto: links.

With target="_blank", browsers attempt to open a new tab for mailto: links, which results in a blank tab or nothing happening instead of launching the default email client.

## Changes

Added a check for mailto: links before the default target="_blank" rendering. mailto: links are now rendered as plain <a> tags without target="_blank", allowing the browser to properly handle the mailto: protocol and open the user's default email client.

Related: #12954 #16243
This commit is contained in:
西村拓朗のアプリ 2026-02-23 13:59:40 +09:00 committed by GitHub
parent d0bb642fc5
commit de866d617b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,6 +36,10 @@ const Link = ({ node, children, ...props }: any) => {
if (!href || !isValidUrl(href))
return <span>{children}</span>
// Handle mailto: links without target="_blank" to allow email client to open directly
if (href.toString().startsWith('mailto:'))
return <a href={href} className={commonClassName}>{children}</a>
return <a href={href} target="_blank" rel="noopener noreferrer" className={commonClassName}>{children || 'Download'}</a>
}
}