From 4515a285a495528fb99262ceaaafa56d139e9ea0 Mon Sep 17 00:00:00 2001 From: Livia Medeiros Date: Thu, 20 Jul 2023 22:33:10 +0900 Subject: [PATCH] fs: remove redundant `nullCheck` PR-URL: https://github.com/nodejs/node/pull/48826 Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Yagiz Nizipli --- lib/fs.js | 4 +--- test/parallel/test-fs-null-bytes.js | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index ddef598126ae16..8c30a842ff1dc4 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1420,14 +1420,12 @@ function mkdirSync(path, options) { /** * An iterative algorithm for reading the entire contents of the `basePath` directory. * This function does not validate `basePath` as a directory. It is passed directly to - * `binding.readdir` after a `nullCheck`. + * `binding.readdir`. * @param {string} basePath * @param {{ encoding: string, withFileTypes: boolean }} options * @returns {string[] | Dirent[]} */ function readdirSyncRecursive(basePath, options) { - nullCheck(basePath, 'path', true); - const withFileTypes = Boolean(options.withFileTypes); const encoding = options.encoding; diff --git a/test/parallel/test-fs-null-bytes.js b/test/parallel/test-fs-null-bytes.js index d4548c02c07009..2851ac657ded33 100644 --- a/test/parallel/test-fs-null-bytes.js +++ b/test/parallel/test-fs-null-bytes.js @@ -66,6 +66,7 @@ check(fs.mkdir, fs.mkdirSync, 'foo\u0000bar', '0755'); check(fs.open, fs.openSync, 'foo\u0000bar', 'r'); check(fs.readFile, fs.readFileSync, 'foo\u0000bar'); check(fs.readdir, fs.readdirSync, 'foo\u0000bar'); +check(fs.readdir, fs.readdirSync, 'foo\u0000bar', { recursive: true }); check(fs.readlink, fs.readlinkSync, 'foo\u0000bar'); check(fs.realpath, fs.realpathSync, 'foo\u0000bar'); check(fs.rename, fs.renameSync, 'foo\u0000bar', 'foobar'); @@ -100,6 +101,7 @@ check(fs.mkdir, fs.mkdirSync, fileUrl, '0755'); check(fs.open, fs.openSync, fileUrl, 'r'); check(fs.readFile, fs.readFileSync, fileUrl); check(fs.readdir, fs.readdirSync, fileUrl); +check(fs.readdir, fs.readdirSync, fileUrl, { recursive: true }); check(fs.readlink, fs.readlinkSync, fileUrl); check(fs.realpath, fs.realpathSync, fileUrl); check(fs.rename, fs.renameSync, fileUrl, 'foobar'); @@ -131,6 +133,7 @@ check(fs.mkdir, fs.mkdirSync, fileUrl2, '0755'); check(fs.open, fs.openSync, fileUrl2, 'r'); check(fs.readFile, fs.readFileSync, fileUrl2); check(fs.readdir, fs.readdirSync, fileUrl2); +check(fs.readdir, fs.readdirSync, fileUrl2, { recursive: true }); check(fs.readlink, fs.readlinkSync, fileUrl2); check(fs.realpath, fs.realpathSync, fileUrl2); check(fs.rename, fs.renameSync, fileUrl2, 'foobar');