Skip to content

Commit

Permalink
fs: use missing validator
Browse files Browse the repository at this point in the history
The `fs` lib module's `mkdtemp()` and `mkdtempSync()` methods are missing a validator.
  • Loading branch information
VoltrexKeyva committed Jun 13, 2021
1 parent 67d4a3f commit 6b65841
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const {
codes: {
ERR_FS_FILE_TOO_LARGE,
ERR_INVALID_ARG_VALUE,
ERR_INVALID_ARG_TYPE,
ERR_FEATURE_UNAVAILABLE_ON_PLATFORM,
},
AbortError,
Expand Down Expand Up @@ -136,6 +135,7 @@ const {
validateEncoding,
validateFunction,
validateInteger,
validateString,
} = require('internal/validators');

const watchers = require('internal/fs/watchers');
Expand Down Expand Up @@ -2712,9 +2712,8 @@ realpath.native = (path, options, callback) => {
function mkdtemp(prefix, options, callback) {
callback = makeCallback(typeof options === 'function' ? options : callback);
options = getOptions(options, {});
if (!prefix || typeof prefix !== 'string') {
throw new ERR_INVALID_ARG_TYPE('prefix', 'string', prefix);
}

validateString(prefix, 'prefix');
nullCheck(prefix, 'prefix');
warnOnNonPortableTemplate(prefix);
const req = new FSReqCallback();
Expand All @@ -2730,9 +2729,8 @@ function mkdtemp(prefix, options, callback) {
*/
function mkdtempSync(prefix, options) {
options = getOptions(options, {});
if (!prefix || typeof prefix !== 'string') {
throw new ERR_INVALID_ARG_TYPE('prefix', 'string', prefix);
}

validateString(prefix, 'prefix');
nullCheck(prefix, 'prefix');
warnOnNonPortableTemplate(prefix);
const path = `${prefix}XXXXXX`;
Expand Down

0 comments on commit 6b65841

Please sign in to comment.