If a hex string has an odd number of bytes, the last byte is just
ignored in Node.js.
}
}
- // must be an even number of digits
var strLen = string.length
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
if (length > strLen / 2) {
length = strLen / 2
assert.strictEqual(hexb2[i], hexb[i]);
}
}
-/*
+
// Test single hex character is discarded.
assert.strictEqual(Buffer.from('A', 'hex').length, 0);
// Test that if a trailing character is discarded, rest of string is processed.
assert.deepStrictEqual(Buffer.from('Abx', 'hex'), Buffer.from('Ab', 'hex'));
-*/
+
// Test single base64 char encodes as 0.
assert.strictEqual(Buffer.from('A', 'base64').length, 0);