mirror of
https://github.com/Blah-IM/typescript-core.git
synced 2025-04-30 16:21:10 +00:00
fix: Use new URL()
for better compatibility.
Some checks are pending
Deno / test (push) Waiting to run
Some checks are pending
Deno / test (push) Waiting to run
This commit is contained in:
parent
91c0ecb704
commit
4674565d64
1 changed files with 13 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue