From ea18376bc80c46621dd2c80a4eef8ff6556ada52 Mon Sep 17 00:00:00 2001 From: Alex Butler Date: Fri, 25 May 2018 15:39:41 +0100 Subject: [PATCH] Workaround UNC path fs::canonicalize return Reported in #838 Also see https://github.com/rust-lang/rust/issues/42869 --- src/cmd.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cmd.rs b/src/cmd.rs index 6ba6b02d7bd..3c1c114799f 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -398,10 +398,17 @@ fn initialize(root_path: String) -> Request { } fn url(file_name: &str) -> Url { - let path = Path::new(file_name) + let canonical = Path::new(file_name) .canonicalize() .expect("Could not canonicalize file name"); - Url::parse(&format!("file://{}", path.to_str().unwrap())).expect("Bad file name") + let mut path = canonical.to_str().unwrap(); + + // workaround for UNC path see https://github.com/rust-lang/rust/issues/42869 + if path.starts_with(r"\\?\") { + path = &path[r"\\?\".len()..]; + } + + Url::parse(&format!("file://{}", path)).expect("Bad file name") } fn next_id() -> usize {