Skip to content

ToNamespacedPath doesn't work with device names #54180

Description

@rotu

Version

v20.16.0

Platform

Microsoft Windows NT 10.0.22635.0 x64

Subsystem

No response

What steps will reproduce the bug?

import path from 'node:path'
console.log(path.toNamespacedPath("COM3"))

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

This should print:

\\.\COM3

which is the fully qualified path in the device namespace

What do you see instead?

This prints the illegal path:

\\?\C:\Users\dan\COM3

Additional information

Reference for legal path name: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces
Additionally console.log(url.pathToFileURL("COM3").href) prints an invalid URL, but I'm not sure if there is a corresponding valid file: URL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pathIssues and PRs related to the path subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions