diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 9e80bf1d60..42133b3df3 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -258,6 +258,10 @@ impl SanitizedPath { #[cfg(target_os = "windows")] { + let path = match path.to_str().and_then(|s| s.strip_prefix(r"\\?\UNC\")) { + Some(rest) => PathBuf::from(format!(r"\\{rest}")).into(), + None => path, + }; let simplified = dunce::simplified(path.as_ref()); if simplified == path.as_ref() { // safe because `Path` and `SanitizedPath` have the same repr and Drop impl @@ -2741,6 +2745,14 @@ mod tests { ); } + #[perf] + #[cfg(target_os = "windows")] + fn test_sanitized_path_verbatim_unc() { + let path: Arc = PathBuf::from("\\\\?\\UNC\\server\\share\\file.txt").into(); + let sanitized_path = SanitizedPath::from_arc(path); + assert_eq!(sanitized_path.to_string(), "\\\\server\\share\\file.txt"); + } + #[perf] fn test_compare_numeric_segments() { // Helper function to create peekable iterators and test