Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Typed drive and server paths are written as Explorer writes them (e:/ -> E:\)

gelenmedya7ea8e1cb07a0
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rs
index ea11070e..55343a6b 100644
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@ -5943,8 +5943,8 @@ fn parse_location(text: &str) -> Option<Location> {
if lower == "home" || lower == "ana sayfa" {
return Some(Location::Home);
}
- // Environment variables like %USERPROFILE%
- let expanded = expand_env(t);
+ // Environment variables like %USERPROFILE%; a drive or server path written as Explorer writes it (e:/ -> E:\)
+ let expanded = rf_core::addrcmd::tidy_typed_path(&expand_env(t));
let mut p = PathBuf::from(&expanded);
if expanded.starts_with(crate::aliases::PREFIX) {
// "@name\sub": a folder alias; unknown names fall through as a plain path
diff --git a/crates/rf-core/src/addrcmd.rs b/crates/rf-core/src/addrcmd.rs
index 50d80229..22aabbdb 100644
--- a/crates/rf-core/src/addrcmd.rs
+++ b/crates/rf-core/src/addrcmd.rs
@@ -236,6 +236,39 @@ pub fn expand_vars(s: &str, lookup: &dyn Fn(&str) -> Option<String>) -> String {
out
}
+/// A typed Windows path the way Explorer writes it: `e:/work//notes` becomes `E:\work\notes`, `//nas/media` becomes `\\nas\media`
+/// (Discord, 2026-12-01: "normalising typed paths, e:/ becomes E:\"). Only a path with a drive letter or a `\\server` start is touched;
+/// anything else (a relative name, `ftp://…`, `shell:…`, an alias) comes back as it was. Nothing is read from the disk.
+pub fn tidy_typed_path(s: &str) -> String {
+ let b = s.as_bytes();
+ let drive = b.len() >= 2 && b[0].is_ascii_alphabetic() && b[1] == b':' && !s[2..].starts_with("//");
+ let unc = (s.starts_with(r"\\") || s.starts_with("//")) && !s.contains("://");
+ if !drive && !unc {
+ return s.to_string();
+ }
+ let flipped = s.replace('/', r"\");
+ // separators run together become one, except the two that start a `\\server` path
+ let (head, rest) = if unc { (r"\\", &flipped[2..]) } else { ("", flipped.as_str()) };
+ let mut out = String::with_capacity(s.len());
+ out.push_str(head);
+ let mut last_sep = unc;
+ for c in rest.chars() {
+ if c == '\\' {
+ if last_sep {
+ continue;
+ }
+ last_sep = true;
+ } else {
+ last_sep = false;
+ }
+ out.push(c);
+ }
+ if drive {
+ out.replace_range(0..1, &out[0..1].to_ascii_uppercase());
+ }
+ out
+}
+
#[cfg(test)]
mod tests {
#[test]
@@ -409,3 +442,31 @@ mod tests {
assert!(!is_absolute(r"tools\a"));
}
}
+
+#[cfg(test)]
+mod tidy_tests {
+ use super::tidy_typed_path as t;
+
+ #[test]
+ fn a_drive_path_is_written_as_explorer_writes_it() {
+ assert_eq!(t("e:/"), r"E:\");
+ assert_eq!(t("e:"), "E:");
+ assert_eq!(t("e:/work//notes/"), r"E:\work\notes\");
+ assert_eq!(t(r"c:\Users\me"), r"C:\Users\me");
+ assert_eq!(t(r"C:\Users\\me"), r"C:\Users\me");
+ }
+
+ #[test]
+ fn a_server_path_keeps_its_two_leading_backslashes() {
+ assert_eq!(t("//nas/media/films"), r"\\nas\media\films");
+ assert_eq!(t(r"\\nas\\media"), r"\\nas\media");
+ assert_eq!(t(r"\\?\C:\long"), r"\\?\C:\long");
+ }
+
+ #[test]
+ fn anything_else_is_left_alone() {
+ for s in ["ftp://host/dir", "shell:Downloads", "notes", r"work\notes", "@docs/sub", "http://x.y/z", "c://odd"] {
+ assert_eq!(t(s), s, "{s}");
+ }
+ }
+}