Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix validateAllowedHostnames check

Steven Tey59477d44a36c
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx
index 725e457413..ae1e986c6a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/analytics/allowed-hostnames.tsx
@@ -1,6 +1,5 @@
"use client";
-import { isValidDomain } from "@/lib/api/domains";
import useWorkspace from "@/lib/swr/use-workspace";
import { ThreeDots } from "@/ui/shared/icons";
import {
@@ -10,7 +9,7 @@ import {
LoadingSpinner,
Popover,
} from "@dub/ui";
-import { cn } from "@dub/utils";
+import { cn, validDomainRegex } from "@dub/utils";
import { CheckCircle, Delete } from "lucide-react";
import Link from "next/link";
import {
@@ -76,7 +75,7 @@ const AddHostnameForm = () => {
return;
}
- if (!isValidDomain(hostname)) {
+ if (!validDomainRegex.test(hostname)) {
toast.error("Enter a valid domain.");
return;
}
@@ -105,7 +104,7 @@ const AddHostnameForm = () => {
setHostname("");
};
- const isHostnameValid = isValidDomain(hostname);
+ const isHostnameValid = validDomainRegex.test(hostname);
return (
<form
diff --git a/apps/web/lib/api/allowed-hostnames.ts b/apps/web/lib/api/allowed-hostnames.ts
index 07033ca99e..a703dd02b2 100644
--- a/apps/web/lib/api/allowed-hostnames.ts
+++ b/apps/web/lib/api/allowed-hostnames.ts
@@ -1,4 +1,4 @@
-import { isValidDomain } from "./domains";
+import { validDomainRegex } from "@dub/utils";
import { DubApiError } from "./errors";
const MAX_HOSTNAMES_ALLOWED = 10;
@@ -13,7 +13,7 @@ export const validateAllowedHostnames = async (
allowedHostnames = [...new Set(allowedHostnames)];
const results = await Promise.all(
- allowedHostnames.map((hostname) => isValidDomain(hostname)),
+ allowedHostnames.map((hostname) => validDomainRegex.test(hostname)),
);
const invalidHostnames = results.filter((result) => !result);
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index 986062511b..e88a0b1aa0 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -145,11 +145,6 @@ const NAV_AREAS: SidebarNavAreas<{
icon: Books2,
href: `/${slug}/settings/library`,
},
- {
- name: "Analytics",
- icon: LinesY,
- href: `/${slug}/settings/analytics`,
- },
{
name: "People",
icon: Users6,
@@ -160,6 +155,11 @@ const NAV_AREAS: SidebarNavAreas<{
icon: ConnectedDots,
href: `/${slug}/settings/integrations`,
},
+ {
+ name: "Analytics",
+ icon: LinesY,
+ href: `/${slug}/settings/analytics`,
+ },
{
name: "Security",
icon: ShieldCheck,