|
|
|
|
@ -4,6 +4,7 @@ export function isWebsocketUrl(url: string): boolean {
@@ -4,6 +4,7 @@ export function isWebsocketUrl(url: string): boolean {
|
|
|
|
|
|
|
|
|
|
// copy from nostr-tools/utils
|
|
|
|
|
export function normalizeUrl(url: string): string { |
|
|
|
|
try { |
|
|
|
|
if (url.indexOf('://') === -1) url = 'wss://' + url |
|
|
|
|
const p = new URL(url) |
|
|
|
|
p.pathname = p.pathname.replace(/\/+/g, '/') |
|
|
|
|
@ -13,6 +14,10 @@ export function normalizeUrl(url: string): string {
@@ -13,6 +14,10 @@ export function normalizeUrl(url: string): string {
|
|
|
|
|
p.searchParams.sort() |
|
|
|
|
p.hash = '' |
|
|
|
|
return p.toString() |
|
|
|
|
} catch { |
|
|
|
|
console.error('Invalid URL:', url) |
|
|
|
|
return '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function normalizeHttpUrl(url: string): string { |
|
|
|
|
|