Skip to content

url.pathToFileURL doesn't generate valid URLs for UNC paths #34736

Closed
@mceachen

Description

  • Node.js version: v12.18.3 and v14.8.0

  • Platform: Windows 10 (10.0.19041)

  • Subsystem: url

What steps will reproduce the bug?

const url = require("url")
url.pathToFileURL("\\\\laptop\\My Documents\\FileSchemeURIs.doc")

Expected behavior

As per Microsoft's UNC URI documentation):

file://laptop/My%20Documents/FileSchemeURIs.doc

Actual behavior

URL {
  href: 'file:///laptop/My%20Documents/FileSchemeURIs.doc',
  origin: 'null',
  protocol: 'file:',
  username: '',
  password: '',
  host: '',
  hostname: '',
  port: '',
  pathname: '/laptop/My%20Documents/FileSchemeURIs.doc',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
  1. hostname should be laptop (not '').

  2. pathname should be /My%20Documents/FileSchemeURIs.doc (not be prefixed by /laptop/).

Activity

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

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.good first issueIssues that are suitable for first-time contributors.urlIssues and PRs related to the legacy built-in url module.whatwg-urlIssues and PRs related to the WHATWG URL implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions