Skip to content

Commit 0ab7dc2

Browse files
committed
Update link.tsx
1 parent d1330b6 commit 0ab7dc2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/link.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type RegisteredLinkProps = RegisterLink extends { Link: infer Link }
2222
| `https://${string}`
2323
| `http://${string}`
2424
| `#${string}`
25-
| `${string}:${string}`;
25+
| string; // to handle mailto:mail@domain.fr or tel:0123456789 ...
2626
})
2727
: Omit<HTMLAnchorProps, "children">;
2828

@@ -94,10 +94,11 @@ export function setLink(params: { Link: typeof Link }): void {
9494
return <a href={target} {...rest} />;
9595
}
9696

97-
external_actions: {
98-
const regex = /^[^:]+:[^:]+$/;
97+
uri_scheme: {
98+
// Check if the 'target' starts with a valid URI scheme (e.g., 'mailto:', 'tel:', 'skype:', 'facetime:', etc.)
99+
const regex = /^[a-z]+:/;
99100
if (target === undefined || !regex.test(target)) {
100-
break external_actions;
101+
break uri_scheme;
101102
}
102103

103104
return <a href={target} {...rest} />;

0 commit comments

Comments
 (0)