Skip to content

Commit 24ba53b

Browse files
committed
#152 - ignore undefined properties
1 parent d54a270 commit 24ba53b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,7 @@ test('userProperties null prototype', t => {
30683068
topicAliasMaximum: 456,
30693069
requestResponseInformation: true,
30703070
requestProblemInformation: true,
3071+
correlationData: undefined,
30713072
userProperties: {
30723073
test: 'test'
30733074
},

writeToStream.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,9 @@ function getProperties (stream, properties) {
993993
let propLength = 0
994994
let propValueLength = 0
995995
const propValue = properties[propName]
996-
if (Array.isArray(propValue)) {
996+
if (propValue === undefined) {
997+
continue
998+
} else if (Array.isArray(propValue)) {
997999
for (let valueIndex = 0; valueIndex < propValue.length; valueIndex++) {
9981000
propValueLength = getLengthProperty(propName, propValue[valueIndex])
9991001
if (!propValueLength) { return false }
@@ -1101,7 +1103,7 @@ function writeProperties (stream, properties, propertiesLength) {
11011103
/* write properties to stream */
11021104
writeVarByteInt(stream, propertiesLength)
11031105
for (const propName in properties) {
1104-
if (Object.prototype.hasOwnProperty.call(properties, propName) && properties[propName] !== null) {
1106+
if (Object.prototype.hasOwnProperty.call(properties, propName) && properties[propName] != null) {
11051107
const value = properties[propName]
11061108
if (Array.isArray(value)) {
11071109
for (let valueIndex = 0; valueIndex < value.length; valueIndex++) {

0 commit comments

Comments
 (0)