@@ -15,7 +15,7 @@ const {
1515const { validateBoolean } = require ( 'internal/validators' ) ;
1616const { MemoryProvider } = require ( 'internal/vfs/providers/memory' ) ;
1717const path = require ( 'path' ) ;
18- const { posix : pathPosix , isAbsolute , resolve : resolvePath } = path ;
18+ const { posix : pathPosix , resolve : resolvePath , toNamespacedPath } = path ;
1919const { join : joinPath } = pathPosix ;
2020const {
2121 isUnderMountPoint,
@@ -51,6 +51,19 @@ const kLayerId = Symbol('kLayerId');
5151// messages.
5252let nextLayerId = 0 ;
5353
54+ /**
55+ * Normalizes paths for mount-point comparisons. On Windows, `path.resolve('/x')`
56+ * yields `C:\x`, while loader internals often pass namespaced paths like
57+ * `\\?\C:\x`. Compare using a single canonical representation so POSIX-style
58+ * rooted test paths, drive-absolute paths, and namespaced paths all route to the
59+ * same VFS mount.
60+ * @param {string } inputPath
61+ * @returns {string }
62+ */
63+ function normalizeMountedPath ( inputPath ) {
64+ return toNamespacedPath ( resolvePath ( inputPath ) ) ;
65+ }
66+
5467// Lazy-loaded VFS setup
5568let registerVFS ;
5669let deregisterVFS ;
@@ -195,8 +208,9 @@ class VirtualFileSystem {
195208 if ( ! this [ kMounted ] || ! this [ kMountPoint ] ) {
196209 return false ;
197210 }
198- const normalized = isAbsolute ( inputPath ) ? inputPath : resolvePath ( inputPath ) ;
199- return isUnderMountPoint ( normalized , this [ kMountPoint ] ) ;
211+ const normalized = normalizeMountedPath ( inputPath ) ;
212+ const mountPoint = normalizeMountedPath ( this [ kMountPoint ] ) ;
213+ return isUnderMountPoint ( normalized , mountPoint ) ;
200214 }
201215
202216 // ==================== Path Resolution ====================
@@ -209,11 +223,12 @@ class VirtualFileSystem {
209223 */
210224 #toProviderPath( inputPath ) {
211225 if ( this [ kMounted ] && this [ kMountPoint ] ) {
212- const resolved = isAbsolute ( inputPath ) ? inputPath : resolvePath ( inputPath ) ;
213- if ( ! isUnderMountPoint ( resolved , this [ kMountPoint ] ) ) {
226+ const resolved = normalizeMountedPath ( inputPath ) ;
227+ const mountPoint = normalizeMountedPath ( this [ kMountPoint ] ) ;
228+ if ( ! isUnderMountPoint ( resolved , mountPoint ) ) {
214229 throw createENOENT ( 'open' , inputPath ) ;
215230 }
216- return getRelativePath ( resolved , this [ kMountPoint ] ) ;
231+ return getRelativePath ( resolved , mountPoint ) ;
217232 }
218233 return pathPosix . normalize ( inputPath ) ;
219234 }
0 commit comments