fix: url loading for cell creation

This commit is contained in:
Danish Arora 2025-11-19 00:29:06 -05:00
parent 4c2f7ab341
commit 6ddc2a47ad
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E

View File

@ -23,7 +23,6 @@ import {
DialogTrigger,
} from '@/components/ui/dialog';
import { useToast } from '@/hooks/use-toast';
import { urlLoads } from '@/utils';
const formSchema = z.object({
title: z
@ -39,8 +38,13 @@ const formSchema = z.object({
.optional()
.refine(
val => {
if (!val) return true;
return urlLoads(val);
if (!val || val.trim() === '') return true;
try {
const urlObj = new URL(val);
return urlObj.protocol === 'http:' || urlObj.protocol === 'https:';
} catch {
return false;
}
},
{
message: 'Icon must be a valid URL',