Skip to content

Commit 9592ede

Browse files
authored
fix(sidebar): use RegExp for outgoing link detection (#7844)
* fix(sidebar): use RegExp for outgoing link detection Signed-off-by: Aviv Keller <[email protected]> * also use regex in Link --------- Signed-off-by: Aviv Keller <[email protected]>
1 parent 7186d72 commit 9592ede

File tree

2 files changed

+2
-2
lines changed
  • apps/site/components
  • packages/ui-components/Containers/Sidebar/SidebarItem

2 files changed

+2
-2
lines changed

apps/site/components/Link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const Link: FC<HTMLProps<HTMLAnchorElement>> = ({
77
href,
88
...props
99
}) => {
10-
if (!href || href.toString().startsWith('http')) {
10+
if (!href || /^https?:/.test(href.toString())) {
1111
return (
1212
<a href={href} {...props}>
1313
{children}

packages/ui-components/Containers/Sidebar/SidebarItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const SidebarItem: FC<SidebarItemProps> = ({
3636
)}
3737
<span className={styles.label}>{label}</span>
3838

39-
{link.startsWith('http') && <ArrowUpRightIcon className={styles.icon} />}
39+
{/^https?:/.test(link) && <ArrowUpRightIcon className={styles.icon} />}
4040
</BaseActiveLink>
4141
);
4242

0 commit comments

Comments
 (0)