diff --git a/local/recipes/tui/tlc/source/src/vfs/path.rs b/local/recipes/tui/tlc/source/src/vfs/path.rs index 1af5ff80f2..fcb46de4fb 100644 --- a/local/recipes/tui/tlc/source/src/vfs/path.rs +++ b/local/recipes/tui/tlc/source/src/vfs/path.rs @@ -150,6 +150,12 @@ impl VfsPath { /// `cpio://`, `zip://`. Anything without a known scheme prefix is /// treated as a local path (with `~`/env expansion). pub fn parse(s: &str) -> Result { + // `file://` is the standard URL scheme for local files; + // accept it as an alias for `local://` (some tools pass + // file:// URLs from text editors, browsers, etc.). + if let Some(rest) = s.strip_prefix("file://") { + return Ok(Self::local(PathBuf::from(rest))); + } if let Some(rest) = s.strip_prefix("local://") { return Ok(Self::local(PathBuf::from(rest))); } @@ -420,6 +426,13 @@ mod tests { assert_eq!(p.as_path(), Path::new("/etc")); } + #[test] + fn parse_file_scheme_is_alias_for_local() { + let p = VfsPath::parse("file:///etc/passwd").unwrap(); + assert_eq!(p.scheme(), "local"); + assert_eq!(p.as_path(), Path::new("/etc/passwd")); + } + #[test] fn parse_tilde_expands() { let p = VfsPath::parse("~").unwrap();