mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-11 01:28:51 +00:00
Expose relay funcs (#31)
This commit is contained in:
committed by
GitHub
parent
ae717a1a4a
commit
1b798b2eee
13
relay.js
13
relay.js
@@ -83,7 +83,7 @@ export function relayConnect(url, onNotice = () => {}, onError = () => {}) {
|
||||
if (data.length >= 1) {
|
||||
switch (data[0]) {
|
||||
case 'NOTICE':
|
||||
if (data.length != 2) {
|
||||
if (data.length !== 2) {
|
||||
// ignore empty or malformed notice
|
||||
return
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export function relayConnect(url, onNotice = () => {}, onError = () => {}) {
|
||||
onNotice(data[1])
|
||||
return
|
||||
case 'EOSE':
|
||||
if (data.length != 2) {
|
||||
if (data.length !== 2) {
|
||||
// ignore malformed EOSE
|
||||
return
|
||||
}
|
||||
@@ -101,7 +101,7 @@ export function relayConnect(url, onNotice = () => {}, onError = () => {}) {
|
||||
}
|
||||
return
|
||||
case 'EVENT':
|
||||
if (data.length != 3) {
|
||||
if (data.length !== 3) {
|
||||
// ignore malformed EVENT
|
||||
return
|
||||
}
|
||||
@@ -114,6 +114,13 @@ export function relayConnect(url, onNotice = () => {}, onError = () => {}) {
|
||||
eventListeners[channel](event)
|
||||
}
|
||||
return
|
||||
|
||||
case 'OK':
|
||||
if (data.length !== 4) {
|
||||
// ignore malformed EVENT
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user