fix: Use new URL() for better compatibility.
Some checks are pending
Deno / test (push) Waiting to run

This commit is contained in:
Shibo Lyu 2025-04-30 22:49:35 +08:00
parent 91c0ecb704
commit 4674565d64

View file

@ -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;
}
}