Skip to content

Commit

Permalink
Update link.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Mar 4, 2024
1 parent d1330b6 commit 0ab7dc2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type RegisteredLinkProps = RegisterLink extends { Link: infer Link }
| `https://${string}`
| `http://${string}`
| `#${string}`
| `${string}:${string}`;
| string; // to handle mailto:mail@domain.fr or tel:0123456789 ...
})
: Omit<HTMLAnchorProps, "children">;

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

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

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

0 comments on commit 0ab7dc2

Please sign in to comment.