From 69e896c221be26cefdf1030f527ebf9e1e4ce1f7 Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 29 Aug 2024 13:44:47 -0700 Subject: [Video] Properly get the service auth aud from the session (#5025) --- src/lib/strings/url-helpers.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/strings/url-helpers.ts') 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}` +} -- cgit 1.4.1