diff options
author | Hailey <me@haileyok.com> | 2024-08-29 13:44:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 13:44:47 -0700 |
commit | 69e896c221be26cefdf1030f527ebf9e1e4ce1f7 (patch) | |
tree | 0de2deb9d863e10744714f7ff7004e6a3684887c /src/lib/strings/url-helpers.ts | |
parent | 91fe41670f0060e6d648a88fd8255caa42eb3143 (diff) | |
download | voidsky-69e896c221be26cefdf1030f527ebf9e1e4ce1f7.tar.zst |
[Video] Properly get the service auth aud from the session (#5025)
Diffstat (limited to 'src/lib/strings/url-helpers.ts')
-rw-r--r-- | src/lib/strings/url-helpers.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/strings/url-helpers.ts b/src/lib/strings/url-helpers.ts index 0407df757..95c6bcead 100644 --- a/src/lib/strings/url-helpers.ts +++ b/src/lib/strings/url-helpers.ts @@ -339,3 +339,21 @@ export function shortLinkToHref(url: string): string { return url } } + +export function getHostnameFromUrl(url: string): string | null { + let urlp + try { + urlp = new URL(url) + } catch (e) { + return null + } + return urlp.hostname +} + +export function getServiceAuthAudFromUrl(url: string): string | null { + const hostname = getHostnameFromUrl(url) + if (!hostname) { + return null + } + return `did:web:${hostname}` +} |