Skip to content

Commit

Permalink
crypto: remove obsolete encoding check
Browse files Browse the repository at this point in the history
This renames the parameters for clarity and removes the check for
undefined encoding. That will always default to `utf8`.

PR-URL: #26809
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR committed Mar 27, 2019
1 parent 92db780 commit 751c92d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit 751c92d

Please sign in to comment.