-
-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Description
If we resolve
an absolute path on windows, we get back a path that is not a valid file:
URL:
import { resolve } from 'import-meta-resolve';
import { pathToFileURL } from 'url';
console.log(
resolve(
"C:\\Users",
pathToFileURL("C:\\Users\\X\\")
)
);
prints "c:\Users"
expected result: "file:///c/Users"
This is inconsistent with the behavior on posix:
import { resolve } from 'import-meta-resolve';
import { pathToFileURL } from 'url';
console.log(
resolve(
"/home",
pathToFileURL("/home/x/")
)
);
prints "file:///home"
I noticed this issue because Node will refuse to import()
absolute paths on windows that are not valid file:
URLs. If we're using resolve on user-provided paths and then import()
ing them, it's reasonable for users to expect an absolute path to work.
Metadata
Metadata
Assignees
Labels
No labels