coracle
coracle copied to clipboard
Can't Add Relay URI with Port Definition
When I try to use ws://dev.local:7777 as a relay, I receive the following error: "Please provide a valid relay URL."
This error is triggered by the isShareableRelayUrl function in node_modules/@welshman/util/build/Relay.mjs:
export const isShareableRelayUrl = (url) => {
var _a;
return Boolean(typeof url === 'string' &&
// Is it actually a websocket url and has a dot
url.match(/^wss:\/\/.+\..+/) &&
// Sometimes bugs cause multiple relays to get concatenated
((_a = url.match(/:\/\//g)) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
// It shouldn't have any whitespace, url-encoded or otherwise
!url.match(/\s|%/) &&
// Don't match stuff with a port number
!url.slice(6).match(/:\d+/) &&
// Don't match stuff with a numeric tld
!url.slice(6).match(/\.\d+\b/) &&
// Don't match raw ip addresses
!url.slice(6).match(/\d+\.\d+\.\d+\.\d+/) &&
// Skip nostr.wine's virtual relays
!url.slice(6).match(/\/npub/));
};
The relevant part is:
// Don't match stuff with a port number
!url.slice(6).match(/:\d+/) &&
This doesn't seem right. ws://dev.local:7777 is a valid relay URI and should be allowed.
My intention is to use a local cache relay as read-only and other relays as write-only to achieve the fastest possible experience with my locally running client.