Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

chore: add blocked pathname to slug input

Marc Seitz8928714d9070
diff --git a/components/links/link-sheet/domain-section.tsx b/components/links/link-sheet/domain-section.tsx
index 7af41ecf..59da0667 100644
--- a/components/links/link-sheet/domain-section.tsx
+++ b/components/links/link-sheet/domain-section.tsx
@@ -7,6 +7,7 @@ import { AddDomainModal } from "@/components/domains/add-domain-modal";
import { mutate } from "swr";
import Link from "next/link";
import { useTeam } from "@/context/team-context";
+import { BLOCKED_PATHNAMES } from "@/lib/constants";
export default function DomainSection({
data,
@@ -76,9 +77,18 @@ export default function DomainSection({
value={data.slug || ""}
pattern="[\p{L}\p{N}\p{Pd}]+"
onInvalid={(e) => {
- e.currentTarget.setCustomValidity(
- "Only letters, numbers, and '-' are allowed.",
- );
+ const currentValue = e.currentTarget.value;
+ const isBlocked = BLOCKED_PATHNAMES.includes(`/${currentValue}`);
+
+ if (isBlocked) {
+ e.currentTarget.setCustomValidity(
+ "This pathname is blocked. Please choose another one.",
+ );
+ } else {
+ e.currentTarget.setCustomValidity(
+ "Only letters, numbers, and '-' are allowed.",
+ );
+ }
}}
autoComplete="off"
className={cn(
@@ -87,8 +97,17 @@ export default function DomainSection({
)}
placeholder="deck"
onChange={(e) => {
- e.currentTarget.setCustomValidity("");
- setData({ ...data, slug: e.target.value });
+ const currentValue = e.target.value;
+ const isBlocked = BLOCKED_PATHNAMES.includes(`/${currentValue}`);
+
+ if (isBlocked) {
+ e.currentTarget.setCustomValidity(
+ "This pathname is blocked. Please choose another one.",
+ );
+ } else {
+ e.currentTarget.setCustomValidity("");
+ }
+ setData({ ...data, slug: currentValue });
}}
aria-invalid="true"
/>
diff --git a/lib/constants.ts b/lib/constants.ts
index f3b6eaa9..53cd0c4e 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -49,4 +49,5 @@ export const BLOCKED_PATHNAMES = [
"/server-status",
"/wordpress",
"/_all_dbs",
+ "/wp-json",
];