summaryrefslogtreecommitdiff
path: root/std/path/posix.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-07-24 02:37:11 +0100
committerGitHub <noreply@github.com>2020-07-23 21:37:11 -0400
commita8f74aa381c99e9c3c3d8fdfde02919966a3a824 (patch)
treed1dc35a1d56bb1845f2389313eda5887682a6632 /std/path/posix.ts
parentb61347b2552cb7159ee3e82c5e9ca5a76e73c3f8 (diff)
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.
Diffstat (limited to 'std/path/posix.ts')
-rw-r--r--std/path/posix.ts3
1 files changed, 2 insertions, 1 deletions
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/");
}