diff --git a/lib/key-encoder.js b/lib/key-encoder.js index 286e522..ef2ea53 100644 --- a/lib/key-encoder.js +++ b/lib/key-encoder.js @@ -85,7 +85,7 @@ KeyEncoder.prototype.encodePrivate = function(privateKey, originalFormat, destin /* Parse the incoming private key and convert it to a private key object */ if (originalFormat === 'raw') { - if (!typeof privateKey === 'string') { + if (typeof privateKey !== 'string') { throw 'private key must be a string' } var privateKeyObject = this.options.curve.keyFromPrivate(privateKey, 'hex'), @@ -101,7 +101,7 @@ KeyEncoder.prototype.encodePrivate = function(privateKey, originalFormat, destin } privateKeyObject = ECPrivateKeyASN.decode(privateKey, 'der') } else if (originalFormat === 'pem') { - if (!typeof privateKey === 'string') { + if (typeof privateKey !== 'string') { throw 'private key must be a string' } privateKeyObject = ECPrivateKeyASN.decode(privateKey, 'pem', this.options.privatePEMOptions) @@ -126,7 +126,7 @@ KeyEncoder.prototype.encodePublic = function(publicKey, originalFormat, destinat /* Parse the incoming public key and convert it to a public key object */ if (originalFormat === 'raw') { - if (!typeof publicKey === 'string') { + if (typeof publicKey !== 'string') { throw 'public key must be a string' } publicKeyObject = this.publicKeyObject(publicKey) @@ -140,7 +140,7 @@ KeyEncoder.prototype.encodePublic = function(publicKey, originalFormat, destinat } publicKeyObject = SubjectPublicKeyInfoASN.decode(publicKey, 'der') } else if (originalFormat === 'pem') { - if (!typeof publicKey === 'string') { + if (typeof publicKey !== 'string') { throw 'public key must be a string' } publicKeyObject = SubjectPublicKeyInfoASN.decode(publicKey, 'pem', this.options.publicPEMOptions) @@ -160,4 +160,4 @@ KeyEncoder.prototype.encodePublic = function(publicKey, originalFormat, destinat } } -module.exports = KeyEncoder \ No newline at end of file +module.exports = KeyEncoder