Merge pull request #948 from timlrx/fix/email-domain

Fix email domain validation
This commit is contained in:
Timothy 2024-06-23 17:50:35 +08:00 committed by GitHub
commit a2fde6dc7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,10 @@ type SocialIconProps = {
}
const SocialIcon = ({ kind, href, size = 8 }: SocialIconProps) => {
if (!href || (kind === 'mail' && !/^mailto:\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/.test(href)))
if (
!href ||
(kind === 'mail' && !/^mailto:[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(href))
)
return null
const SocialSvg = components[kind]