fix: jidNormalizedUser should not throw TypeError

This commit is contained in:
Adhiraj Singh
2022-09-27 16:30:08 +05:30
parent b329c73b20
commit b0a7561726

View File

@@ -53,7 +53,12 @@ export const isJidGroup = (jid: string | undefined) => (jid?.endsWith('@g.us'))
/** is the jid the status broadcast */
export const isJidStatusBroadcast = (jid: string) => jid === 'status@broadcast'
export const jidNormalizedUser = (jid: string) => {
const { user, server } = jidDecode(jid)!
export const jidNormalizedUser = (jid: string | undefined) => {
const result = jidDecode(jid)
if(!result) {
return ''
}
const { user, server } = result
return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server as JidServer)
}