fix: revert remaining ?? '' patterns across Utils, WABinary, Signal, and WAUSync files
Completes the comprehensive revert of defensive null coalescing patterns introduced in PRs 124-129. These patterns (e.g. `value ?? ''`) silently produced empty strings instead of failing fast, causing subtle bugs like malformed JIDs and broken Signal session lookups. Files: libsignal.ts, messages-recv.ts, chat-utils.ts, generics.ts, history.ts, messages-media.ts, messages.ts, process-message.ts, validate-connection.ts, jid-utils.ts, UsyncBotProfileProtocol.ts https://claude.ai/code/session_01XaA7GwNaB6azTHFYQ8WEpB
This commit is contained in:
@@ -63,7 +63,7 @@ export const jidDecode = (jid: string | undefined): FullJid | undefined => {
|
||||
const userCombined = jid.slice(0, sepIdx)
|
||||
|
||||
const [userAgent, device] = userCombined.split(':')
|
||||
const [user, agent] = (userAgent ?? '').split('_')
|
||||
const [user, agent] = userAgent!.split('_')
|
||||
|
||||
let domainType = WAJIDDomains.WHATSAPP
|
||||
if (server === 'lid') {
|
||||
@@ -78,7 +78,7 @@ export const jidDecode = (jid: string | undefined): FullJid | undefined => {
|
||||
|
||||
return {
|
||||
server: server as JidServer,
|
||||
user: user ?? '',
|
||||
user: user!,
|
||||
domainType,
|
||||
device: device ? +device : undefined
|
||||
}
|
||||
@@ -114,7 +114,7 @@ export const isAnyPnUser = (jid: string | undefined) =>
|
||||
|
||||
const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/
|
||||
|
||||
export const isJidBot = (jid: string | undefined) => jid && botRegexp.test(jid.split('@')[0] ?? '') && jid.endsWith('@c.us')
|
||||
export const isJidBot = (jid: string | undefined) => jid && botRegexp.test(jid.split('@')[0]!) && jid.endsWith('@c.us')
|
||||
|
||||
export const jidNormalizedUser = (jid: string | undefined) => {
|
||||
const result = jidDecode(jid)
|
||||
|
||||
Reference in New Issue
Block a user