Skip to content

Commit

Permalink
Cleaner case distinction in decode function
Browse files Browse the repository at this point in the history
  • Loading branch information
M4t7e committed Aug 25, 2023
1 parent 2741e95 commit e807707
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ name.decode = function (buf, offset, { mail = false } = {}) {
if (totalLength > 254) {
throw new Error('Cannot decode name (name too long)')
}
let label = buf.toString('utf-8', offset, offset + len)
if (mail) {
list.push(buf.toString('utf-8', offset, offset + len).replace(/\./g, '\\.'))
} else {
list.push(buf.toString('utf-8', offset, offset + len))
label = label.replace(/\./g, '\\.')
}
list.push(label)
offset += len
consumedBytes += jumped ? 0 : len
} else if ((len & 0xc0) === 0xc0) {
Expand Down

0 comments on commit e807707

Please sign in to comment.