Skip to content

Commit

Permalink
Fix 66 and 67 id messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vphelipe authored Jan 31, 2025
1 parent c39efc9 commit df44b17
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/WABinary/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,19 @@ const encodeBinaryNodeInner = (

return true
}

const isHex = (str: string) => {
if(str.length > TAGS.PACKED_MAX) {
return false
}

for(const char of str) {
const isInNibbleRange = char >= '0' && char <= '9'
if(!isInNibbleRange && !(char >= 'A' && char <= 'F') && !(char >= 'a' && char <= 'f')) {
return false
}
}

return true
}

const isHex = (str) => {
if (str.length > TAGS.PACKED_MAX) {
return false;
}
for (const char of str) {
const isInNibbleRange = char >= '0' && char <= '9';
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
return false;
}
}
return true;
};

const writeString = (str: string) => {
const tokenIndex = TOKEN_MAP[str]
Expand All @@ -189,15 +187,15 @@ const encodeBinaryNodeInner = (
pushByte(tokenIndex.index)
} else if(isNibble(str)) {
writePackedBytes(str, 'nibble')
} else if(isHex(str)) {
writePackedBytes(str, 'hex')
} else if(str) {
const decodedJid = jidDecode(str)
if(decodedJid) {
writeJid(decodedJid)
} else {
writeStringRaw(str)
}
} else if(isHex(str)) {
writePackedBytes(str, 'hex')
}
}

Expand Down

0 comments on commit df44b17

Please sign in to comment.