From a8f74aa381c99e9c3c3d8fdfde02919966a3a824 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Fri, 24 Jul 2020 02:37:11 +0100 Subject: fix: Improve URL compatibility (#6807) - Fix protocol regex. - Truncate repeated leading slashes in file paths. - Make drive letter support platform-independent. - Drop the hostname if a drive letter is parsed. - Fix drive letter normalization and basing. - Allow basing over the host. - Fix same-protocol basing. - Remove Windows UNC path support. - Reverts #6418. This is non-standard. Wouldn't be too much of a problem but it makes other parts of the spec hard to realize. --- std/path/posix.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'std/path/posix.ts') diff --git a/std/path/posix.ts b/std/path/posix.ts index 03d07a84a..3c4262203 100644 --- a/std/path/posix.ts +++ b/std/path/posix.ts @@ -435,5 +435,6 @@ export function parse(path: string): ParsedPath { * are ignored. */ export function fromFileUrl(url: string | URL): string { - return new URL(String(url)).pathname; + return (url instanceof URL ? url : new URL(url)).pathname + .replace(/^\/*([A-Za-z]:)(\/|$)/, "$1/"); } -- cgit v1.2.3