Skip to content
File

Blob: src/shared/site-slug.ts

typescript68 lines
1import { z } from "zod";
2 
3export const SITE_RESERVED_SLUGS = new Set([
4 "www",
5 "api",
6 "app",
7 "admin",
8 "assets",
9 "static",
10 "cdn",
11 "cdn-cgi",
12 "files",
13 "uploads",
14 "media",
15 "img",
16 "images",
17 "mail",
18 "smtp",
19 "mx",
20 "email",
21 "support",
22 "help",
23 "docs",
24 "blog",
25 "status",
26 "security",
27 "legal",
28 "billing",
29 "dashboard",
30 "login",
31 "auth",
32 "sso",
33 "oauth",
34 "account",
35 "accounts",
36 "signup",
37 "signin",
38 "me",
39 "invite",
40 "share",
41 "s",
42 "site",
43 "sites",
44 "embed",
45 "oembed",
46 "link",
47 "bland",
48 "dev",
49 "staging",
50 "preview",
51 "test",
52 "root",
53 "origin",
54 "worker",
55 "workers",
56 "r2",
57]);
58 
59export const sitesSlug = z
60 .string()
61 .min(1)
62 .max(63)
63 .regex(
64 /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,
65 "Slug must be lowercase alphanumeric with hyphens, cannot start or end with a hyphen",
66 )
67 .refine((s) => !SITE_RESERVED_SLUGS.has(s), "This slug is reserved");