From f88c32e43159eee384bb109669dc9b2673e73dcb Mon Sep 17 00:00:00 2001 From: Scott Trinh Date: Tue, 7 Nov 2023 08:32:18 -0500 Subject: [PATCH] JSON.stringify URLs and check URL validity --- shared/studio/tabs/auth/state/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/shared/studio/tabs/auth/state/index.tsx b/shared/studio/tabs/auth/state/index.tsx index f28e1b29..15d569f1 100644 --- a/shared/studio/tabs/auth/state/index.tsx +++ b/shared/studio/tabs/auth/state/index.tsx @@ -119,12 +119,25 @@ export class AuthAdminState extends Model({ return "Too many URLs, maximum supported number of URLs is 128." } + const invalidUrls = urlList.filter((u) => { + try { + new URL(u); + return false; + } catch (e) { + return true; + } + }); + + if (invalidUrls.length > 0) { + return `List contained the following invalid URLs: ${invalidUrls}`; + } + return null; }, (urls) => { if (urls === null) return "{}"; const urlList = urls.split("\n").filter((str) => str.trim() !== ""); - return `{${urlList.map((u) => `'${u}'`).join(", ")}}`; + return `{${urlList.map((u) => JSON.stringify(u)).join(", ")}}`; } ),