fix(cli): strings shouldn't be interpreted as file URLs (#6412)

This commit is contained in:
Casper Beyer 2020-06-26 20:29:34 +08:00 committed by GitHub
parent 70463bac7d
commit 175867ab76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View file

@ -110,14 +110,9 @@ function pathFromURLPosix(url: URL): string {
}
export function pathFromURL(pathOrUrl: string | URL): string {
if (typeof pathOrUrl == "string") {
try {
pathOrUrl = new URL(pathOrUrl);
} catch {}
}
if (pathOrUrl instanceof URL) {
if (pathOrUrl.protocol != "file:") {
throw new TypeError("Must be a path string or file URL.");
throw new TypeError("Must be a file URL.");
}
return build.os == "windows"