Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/(dashboard)/control-center/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ function ControlCenterView() {

<div className={"absolute right-0 bottom-0 z-10"}>
<div className={"px-6 py-4"}>
<a href={"https://forms.gle/MKJnVXCiUM1KtxLy6"} target={"_blank"}>
<a href={"https://forms.gle/MKJnVXCiUM1KtxLy6"} target={"_blank"} rel="noopener noreferrer">
<Button variant={"secondary"} size={"xs"}>
<MessageSquareShareIcon size={12} />
Feedback
Expand Down
12 changes: 11 additions & 1 deletion src/components/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ const DropdownMenuItem = React.forwardRef<
},
ref,
) => {
const safeRel = React.useMemo(() => {
if (target !== "_blank") return rel;

const tokens = new Set((rel ?? "").split(/\s+/).filter(Boolean));
tokens.add("noopener");
tokens.add("noreferrer");

return Array.from(tokens).join(" ");
}, [target, rel]);

return (
<DropdownMenuPrimitive.Item
ref={ref}
Expand All @@ -130,7 +140,7 @@ const DropdownMenuItem = React.forwardRef<
{...props}
>
{href ? (
<a href={href} target={target} rel={rel}>
<a href={href} target={target} rel={safeRel}>
{props.children}
</a>
) : (
Expand Down
18 changes: 16 additions & 2 deletions src/components/InlineLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ interface Props extends LinkProps, InlineLinkProps {
children: React.ReactNode;
className?: string;
target?: "_blank" | "_self" | "_parent" | "_top";
rel?: string;
}

interface InlineButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
InlineLinkProps {
children: React.ReactNode;
className?: string;
target?: "_blank" | "_self" | "_parent" | "_top";
}

export const linkVariants = cva(
Expand All @@ -35,8 +35,22 @@ export const linkVariants = cva(
);

export default function InlineLink({ variant = "default", ...props }: Props) {
const safeRel = React.useMemo(() => {
if (props.target !== "_blank") return props.rel;

const tokens = new Set((props.rel ?? "").split(/\s+/).filter(Boolean));
tokens.add("noopener");
tokens.add("noreferrer");

return Array.from(tokens).join(" ");
}, [props.target, props.rel]);

return (
<Link {...props} className={cn(props.className, linkVariants({ variant }))}>
<Link
{...props}
rel={safeRel}
className={cn(props.className, linkVariants({ variant }))}
Comment thread
lorenzbaum marked this conversation as resolved.
>
{props.children}
</Link>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/SidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function SidebarItem({
if (collapsible && mobileNavOpen) return;
if (collapsible && open) return;
if (preventRedirect) return;
if (target == "_blank") return window.open(href, "_blank");
if (target == "_blank") return window.open(href, "_blank", "noopener,noreferrer");
if (mobileNavOpen) toggleMobileNav();
router.push(href);
};
Expand Down
5 changes: 0 additions & 5 deletions src/components/ui/HelpAndSupportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default function HelpAndSupportButton() {
<DropdownMenuItem
href="https://docs.netbird.io/"
target="_blank"
rel="noopener noreferrer"
asChild
>
<div className={"flex gap-3 items-center"}>
Expand All @@ -71,7 +70,6 @@ export default function HelpAndSupportButton() {
<DropdownMenuItem
href="https://docs.netbird.io/help/troubleshooting-client"
target="_blank"
rel="noopener noreferrer"
asChild
>
<div className={"flex gap-3 items-center"}>
Expand All @@ -97,7 +95,6 @@ export default function HelpAndSupportButton() {
<DropdownMenuItem
href="https://forum.netbird.io/"
target="_blank"
rel="noopener noreferrer"
asChild
>
<div className={"flex gap-3 items-center"}>
Expand All @@ -111,7 +108,6 @@ export default function HelpAndSupportButton() {
<DropdownMenuItem
href="https://docs.netbird.io/slack-url"
target="_blank"
rel="noopener noreferrer"
asChild
>
<div className={"flex gap-3 items-center"}>
Expand All @@ -128,7 +124,6 @@ export default function HelpAndSupportButton() {
<DropdownMenuItem
href={"https://forms.gle/TeLw2zrXEdw6RcQ36"}
target={"_blank"}
rel="noopener noreferrer"
asChild
>
<div className={"flex gap-3 items-center"}>
Expand Down
1 change: 1 addition & 0 deletions src/modules/onboarding/OnboardingEnd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const VideoGuide = ({
"border border-nb-gray-900 rounded-lg p-[2px] bg-nb-gray-920 min-w-[160px] max-w-[160px] relative group hover:bg-nb-gray-900 transition-all"
}
target={"_blank"}
rel="noopener noreferrer"
href={href}
>
<span
Expand Down
1 change: 1 addition & 0 deletions src/modules/setup-netbird-modal/AndroidTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function AndroidTab() {
"https://play.google.com/store/apps/details?id=io.netbird.client"
}
target={"_blank"}
rel="noopener noreferrer"
>
<Image
src={GooglePlayButton}
Expand Down
1 change: 1 addition & 0 deletions src/modules/setup-netbird-modal/DockerTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default function DockerTab({
href={"https://docs.docker.com/engine/install/"}
passHref
target={"_blank"}
rel="noopener noreferrer"
>
<Button variant={"primary"}>
<ExternalLinkIcon size={14} />
Expand Down
1 change: 1 addition & 0 deletions src/modules/setup-netbird-modal/IOSTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function IOSTab() {
<Link
href={"https://apps.apple.com/app/netbird-p2p-vpn/id6469329339"}
target={"_blank"}
rel="noopener noreferrer"
>
<Image
src={AppStoreButton}
Expand Down
8 changes: 7 additions & 1 deletion src/modules/setup-netbird-modal/MacOSTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function MacOSTab({
href={"https://pkgs.netbird.io/macos/universal"}
passHref
target={"_blank"}
rel="noopener noreferrer"
>
<Button variant={"primary"}>
<DownloadIcon size={14} />
Expand Down Expand Up @@ -148,7 +149,12 @@ export default function MacOSTab({
<Steps.Step step={1}>
<p>Download and install HomeBrew</p>
<div className={"flex gap-4"}>
<Link href={"https://brew.sh/"} passHref target={"_blank"}>
<Link
href={"https://brew.sh/"}
passHref
target={"_blank"}
rel="noopener noreferrer"
>
<Button variant={"primary"}>
<ExternalLinkIcon size={14} />
HomeBrew Installation Guide
Expand Down