diff --git a/crates/transport-ipc/src/connect.rs b/crates/transport-ipc/src/connect.rs index e6d41ad18bf..d9c10110060 100644 --- a/crates/transport-ipc/src/connect.rs +++ b/crates/transport-ipc/src/connect.rs @@ -1,11 +1,8 @@ use interprocess::local_socket as ls; use std::io; -pub(crate) fn to_name(mut path: &std::ffi::OsStr) -> io::Result> { - if cfg!(windows) { - if let Some(name) = path.as_encoded_bytes().strip_prefix(br"\\.\pipe\") { - path = unsafe { std::ffi::OsStr::from_encoded_bytes_unchecked(name) } - } +pub(crate) fn to_name(path: &std::ffi::OsStr) -> io::Result> { + if cfg!(windows) && !path.as_encoded_bytes().starts_with(br"\\.\pipe\") { ls::ToNsName::to_ns_name::(path) } else { ls::ToFsName::to_fs_name::(path)