diff options
author | Andrey Filatkin <anfilat@mail.ru> | 2020-06-26 20:25:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-26 13:25:13 -0400 |
commit | b049504bee229bc31db2ae8c879101080512fa5c (patch) | |
tree | 34042528a9a62229e2b6aaff5499af666e23ca3a | |
parent | 9107b1ea3f1e83198b35154e02954fab0dc9fa2a (diff) |
fix(cli/disk_cache): Support UNC paths in the typescript DiskCache (#6495)
-rw-r--r-- | cli/disk_cache.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/cli/disk_cache.rs b/cli/disk_cache.rs index 965f8c096..afea71cd2 100644 --- a/cli/disk_cache.rs +++ b/cli/disk_cache.rs @@ -7,7 +7,7 @@ use std::path::Path; use std::path::PathBuf; use std::path::Prefix; use std::str; -use url::Url; +use url::{Host, Url}; #[derive(Clone)] pub struct DiskCache { @@ -80,6 +80,14 @@ impl DiskCache { let disk = (disk_byte as char).to_string(); out.push(disk); } + Prefix::UNC(server, share) + | Prefix::VerbatimUNC(server, share) => { + out.push("UNC"); + let host = Host::parse(server.to_str().unwrap()).unwrap(); + let host = host.to_string().replace(":", "_"); + out.push(host); + out.push(share); + } _ => unreachable!(), } } @@ -201,6 +209,21 @@ mod tests { if cfg!(target_os = "windows") { test_cases.push(("file:///D:/a/1/s/format.ts", "file/D/a/1/s/format.ts")); + // IPv4 localhost + test_cases.push(( + "file://127.0.0.1/d$/a/1/s/format.ts", + "file/UNC/127.0.0.1/d$/a/1/s/format.ts", + )); + // IPv6 localhost + test_cases.push(( + "file://[0:0:0:0:0:0:0:1]/d$/a/1/s/format.ts", + "file/UNC/[__1]/d$/a/1/s/format.ts", + )); + // shared folder + test_cases.push(( + "file://comp/t-share/a/1/s/format.ts", + "file/UNC/comp/t-share/a/1/s/format.ts", + )); } else { test_cases.push(( "file:///std/http/file_server.ts", |