From 1037eee3359717015c75a77ceb0430c230287fe4 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Fri, 31 Dec 2021 22:03:02 -0300 Subject: [PATCH] trim relay url on normalize. --- relay.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/relay.js b/relay.js index 15cf2d3..27dd94d 100644 --- a/relay.js +++ b/relay.js @@ -6,7 +6,7 @@ import {verifySignature} from './event' import {matchFilters} from './filter' export function normalizeRelayURL(url) { - let [host, ...qs] = url.split('?') + let [host, ...qs] = url.trim().split('?') if (host.slice(0, 4) === 'http') host = 'ws' + host.slice(4) if (host.slice(0, 2) !== 'ws') host = 'wss://' + host if (host.length && host[host.length - 1] === '/') host = host.slice(0, -1) @@ -46,7 +46,7 @@ export function relayConnect(url, onNotice = () => {}, onError = () => {}) { } } } - ws.onerror = (err) => { + ws.onerror = err => { console.log('error connecting to relay', url) onError(err) }