bug: url parser

fixes #564
This commit is contained in:
2023-05-17 20:37:25 +01:00
parent 167f1c5e65
commit cefc21709a
3 changed files with 11 additions and 2 deletions

View File

@ -497,6 +497,14 @@ export function getRelayName(url: string) {
return parsedUrl.host + parsedUrl.search;
}
export function getUrlHostname(url?: string) {
try {
return new URL(url ?? "").hostname;
} catch {
return url?.match(/(\S+\.\S+)/i)?.[1] ?? url;
}
}
export interface NostrLink {
type: NostrPrefix;
id: string;