Skip to content

Commit faa5082

Browse files
committedApr 1, 2024
Update create & update url schema
1 parent 0d4fe53 commit faa5082

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
 

‎src/server/schemas/index.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export const CreateLinkSchema = z.object({
1515
.url({
1616
message: "Please enter a valid URL. Include http:// or https://",
1717
})
18+
.regex(/^(?!.*(?:http|https):\/\/(?:slug|slugr)\.vercel\.app).*$/, {
19+
message: "You cannot redirect to the Slug url.",
20+
})
21+
// not contain any blank spaces
1822
.regex(/^\S+$/, {
1923
message: "URL must not contain any blank spaces.",
2024
}),
@@ -39,7 +43,16 @@ export const CreateLinkSchema = z.object({
3943

4044
export const EditLinkSchema = z.object({
4145
id: z.string(),
42-
url: z.string().min(1, { message: "URL is required." }),
46+
url: z
47+
.string()
48+
.min(1, { message: "URL is required." })
49+
.regex(/^(?!.*(?:http|https):\/\/(?:slug|slugr)\.vercel\.app).*$/, {
50+
message: "You cannot redirect to the Slug url.",
51+
})
52+
// not contain any blank spaces
53+
.regex(/^\S+$/, {
54+
message: "URL must not contain any blank spaces.",
55+
}),
4356
slug: z
4457
.string()
4558
.min(1, { message: "Short link is required." })

0 commit comments

Comments
 (0)