Skip to content

Commit 570d886

Browse files
committed
refactor: use positive regex match for listenKey classification
1 parent 7e1a7f4 commit 570d886

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/node-binance-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ export default class Binance {
304304
|| endpoint.includes('@depth')) {
305305
return 'public';
306306
}
307-
// Private: listenKey strings (no @ or ! prefix)
308-
if (!endpoint.includes('@') && !endpoint.startsWith('!')) {
307+
// Private: listenKey is a long alphanumeric string (60+ chars, no @ or !)
308+
if (/^[A-Za-z0-9]{20,}$/.test(endpoint)) {
309309
return 'private';
310310
}
311-
// Market: everything else (aggTrade, markPrice, kline, ticker, miniTicker, forceOrder, etc.)
311+
// Market: aggTrade, markPrice, kline, ticker, miniTicker, forceOrder, etc.
312312
return 'market';
313313
}
314314

0 commit comments

Comments
 (0)