diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-20 13:05:12 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-27 17:05:18 +0100 |
commit | 751c92d9728da6f6f86e443783a61253791cfc2f (patch) | |
tree | 080348d00460556fa4e134ca1df9f8a4bf1e1dc7 /lib/internal/crypto | |
parent | 92db780d9e39cd25b63c031095cf0072ed2aec55 (diff) | |
download | android-node-v8-751c92d9728da6f6f86e443783a61253791cfc2f.tar.gz android-node-v8-751c92d9728da6f6f86e443783a61253791cfc2f.tar.bz2 android-node-v8-751c92d9728da6f6f86e443783a61253791cfc2f.zip |
crypto: remove obsolete encoding check
This renames the parameters for clarity and removes the check for
undefined encoding. That will always default to `utf8`.
PR-URL: https://github.com/nodejs/node/pull/26809
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/crypto')
-rw-r--r-- | lib/internal/crypto/util.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index 6746f2a66c..c8a1f9e927 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -55,13 +55,13 @@ function getDefaultEncoding() { // This is here because many functions accepted binary strings without // any explicit encoding in older versions of node, and we don't want // to break them unnecessarily. -function toBuf(str, encoding) { - if (typeof str === 'string') { - if (encoding === 'buffer' || !encoding) +function toBuf(val, encoding) { + if (typeof val === 'string') { + if (encoding === 'buffer') encoding = 'utf8'; - return Buffer.from(str, encoding); + return Buffer.from(val, encoding); } - return str; + return val; } const getCiphers = cachedResult(() => filterDuplicateStrings(_getCiphers())); |