From 4674565d64a41461e9d390c7cc3623823989b454 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Wed, 30 Apr 2025 22:49:35 +0800 Subject: [PATCH] fix: Use `new URL()` for better compatibility. --- identity/profile.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/identity/profile.ts b/identity/profile.ts index f86fda4..c9ef639 100644 --- a/identity/profile.ts +++ b/identity/profile.ts @@ -20,13 +20,17 @@ export type BlahProfile = { /** Validate the format of an ID URL. */ export function validateIDURLFormat(url: string): boolean { - const idURL = URL.parse(url); - return !!idURL && - idURL.protocol === "https:" && - idURL.pathname === "/" && - !url.endsWith("/") && - !idURL.search && - !idURL.hash && - !idURL.username && - !idURL.password; + try { + const idURL = new URL(url); + return !!idURL && + idURL.protocol === "https:" && + idURL.pathname === "/" && + !url.endsWith("/") && + !idURL.search && + !idURL.hash && + !idURL.username && + !idURL.password; + } catch { + return false; + } }