Skip to content

Commit 4adea6c

Browse files
RafaelGSSrichardlau
authored andcommitted
fs,test: add URL to string to fs.watch
Signed-off-by: RafaelGSS <[email protected]> PR-URL: #51346 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent e9276ba commit 4adea6c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/fs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const {
109109
getValidatedPath,
110110
getValidMode,
111111
handleErrorFromBinding,
112-
possiblyTransformPath,
113112
preprocessSymlinkDestination,
114113
Stats,
115114
getStatFsFromBinding,
@@ -2451,7 +2450,7 @@ function watch(filename, options, listener) {
24512450

24522451
let watcher;
24532452
const watchers = require('internal/fs/watchers');
2454-
const path = possiblyTransformPath(filename);
2453+
const path = getValidatedPath(filename);
24552454
// TODO(anonrig): Remove non-native watcher when/if libuv supports recursive.
24562455
// As of November 2022, libuv does not support recursive file watch on all platforms,
24572456
// e.g. Linux due to the limitations of inotify.

test/fixtures/permission/fs-read.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ const regularFile = __filename;
265265
permission: 'FileSystemRead',
266266
resource: path.toNamespacedPath(blockedFile),
267267
}));
268+
assert.throws(() => {
269+
fs.watch(blockedFileURL, () => {});
270+
}, common.expectsError({
271+
code: 'ERR_ACCESS_DENIED',
272+
permission: 'FileSystemRead',
273+
resource: path.toNamespacedPath(blockedFile),
274+
}));
268275

269276
// doesNotThrow
270277
fs.readdir(allowedFolder, (err) => {
@@ -353,4 +360,4 @@ const regularFile = __filename;
353360
permission: 'FileSystemRead',
354361
resource: path.toNamespacedPath(blockedFile),
355362
}));
356-
}
363+
}

0 commit comments

Comments
 (0)