Restrict to make sure there is an alias

This commit is contained in:
Owen
2026-04-09 17:10:48 -04:00
parent eb771ceda4
commit 333ccb8438
2 changed files with 28 additions and 15 deletions

View File

@@ -62,7 +62,12 @@ const createSiteResourceSchema = z
.strict() .strict()
.refine( .refine(
(data) => { (data) => {
if (data.mode === "host") { if (
data.mode === "host" ||
data.mode == "http" ||
data.mode == "https"
) {
if (data.mode == "host") {
// Check if it's a valid IP address using zod (v4 or v6) // Check if it's a valid IP address using zod (v4 or v6)
const isValidIP = z const isValidIP = z
// .union([z.ipv4(), z.ipv6()]) // .union([z.ipv4(), z.ipv6()])
@@ -72,6 +77,7 @@ const createSiteResourceSchema = z
if (isValidIP) { if (isValidIP) {
return true; return true;
} }
}
// Check if it's a valid domain (hostname pattern, TLD not required) // Check if it's a valid domain (hostname pattern, TLD not required)
const domainRegex = const domainRegex =

View File

@@ -76,7 +76,13 @@ const updateSiteResourceSchema = z
.strict() .strict()
.refine( .refine(
(data) => { (data) => {
if (data.mode === "host" && data.destination) { if (
(data.mode === "host" ||
data.mode == "http" ||
data.mode == "https") &&
data.destination
) {
if (data.mode == "host") {
const isValidIP = z const isValidIP = z
// .union([z.ipv4(), z.ipv6()]) // .union([z.ipv4(), z.ipv6()])
.union([z.ipv4()]) // for now lets just do ipv4 until we verify ipv6 works everywhere .union([z.ipv4()]) // for now lets just do ipv4 until we verify ipv6 works everywhere
@@ -85,6 +91,7 @@ const updateSiteResourceSchema = z
if (isValidIP) { if (isValidIP) {
return true; return true;
} }
}
// Check if it's a valid domain (hostname pattern, TLD not required) // Check if it's a valid domain (hostname pattern, TLD not required)
const domainRegex = const domainRegex =