From 27ba4e0b19d25bb494f9a3506f327e94b447bd84 Mon Sep 17 00:00:00 2001 From: ChaituVR Date: Tue, 15 Oct 2024 12:17:02 +0530 Subject: [PATCH] fix: Allow https in domain --- src/schemas/space.json | 7 ++----- src/utils.ts | 7 +++++++ test/examples/space-starknet-delegation.json | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/schemas/space.json b/src/schemas/space.json index bdc981a65..5e51dd002 100644 --- a/src/schemas/space.json +++ b/src/schemas/space.json @@ -103,12 +103,9 @@ }, "domain": { "type": "string", - "allOf": [ - { "format": "hostname" }, - { "format": "lowercase" } - ], "title": "domain", - "maxLength": 64 + "maxLength": 64, + "format": "domain" }, "strategies": { "type": "array", diff --git a/src/utils.ts b/src/utils.ts index 384739f99..65854283c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -252,6 +252,13 @@ ajv.addFormat('customUrl', { } }); +ajv.addFormat('domain', { + validate: (value: string) => { + if (!value) return false; + return !!value.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/); + } +}); + export async function call(provider, abi: any[], call: any[], options?) { const contract = new Contract(call[0], abi, provider); try { diff --git a/test/examples/space-starknet-delegation.json b/test/examples/space-starknet-delegation.json index 65286fee7..d69ce75cb 100644 --- a/test/examples/space-starknet-delegation.json +++ b/test/examples/space-starknet-delegation.json @@ -16,7 +16,7 @@ "network": "1", "plugins": {}, "twitter": "lootproject", - "domain": "vote.lootproject.abc", + "domain": "https://vote.lootproject.abc", "strategies": [ { "name": "erc721",