Validate website name and domain input on server side
This commit is contained in:
1 parent
eb9a77ea64
commit
715f306a48
2 files changed
+6
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
import type { Prisma } from '@/generated/prisma/client';
|
||||
import { ENTITY_TYPE } from '@/lib/constants';
|
||||
import { DOMAIN_REGEX, ENTITY_TYPE } from '@/lib/constants';
|
||||
import { uuid } from '@/lib/crypto';
|
||||
import { getRecorderConfig, getRecorderEnabled } from '@/lib/recorder';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
@@ -41,8 +41,8 @@ export async function POST(
|
||||
{ params }: { params: Promise<{ websiteId: string }> },
|
||||
) {
|
||||
const schema = z.object({
|
||||
name: z.string().max(100).optional(),
|
||||
domain: z.string().max(500).optional(),
|
||||
name: z.string().trim().min(1).max(100).optional(),
|
||||
domain: z.string().trim().regex(DOMAIN_REGEX).max(500).optional(),
|
||||
shareId: z.string().max(50).nullable().optional(),
|
||||
replayConfig: z
|
||||
.object({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { ENTITY_TYPE } from '@/lib/constants';
|
||||
import { DOMAIN_REGEX, ENTITY_TYPE } from '@/lib/constants';
|
||||
import { uuid } from '@/lib/crypto';
|
||||
import { fetchAccount, fetchTeam } from '@/lib/load';
|
||||
import { getQueryFilters, parseRequest } from '@/lib/request';
|
||||
@@ -37,8 +37,8 @@ export async function GET(request: Request) {
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const schema = z.object({
|
||||
name: z.string().max(100),
|
||||
domain: z.string().max(500),
|
||||
name: z.string().trim().min(1).max(100),
|
||||
domain: z.string().trim().regex(DOMAIN_REGEX).max(500),
|
||||
shareId: z.string().max(50).nullable().optional(),
|
||||
teamId: z.uuid().nullable().optional(),
|
||||
id: z.uuid().nullable().optional(),
|
||||
|
||||
Reference in new issue
Block a user