From 08dbaf519ab8cf3878b379f99b2bf6a93688c466 Mon Sep 17 00:00:00 2001 From: kellito Date: Sun, 5 Jul 2026 18:58:11 +0300 Subject: [PATCH] =?UTF-8?q?tlc:=20Sprint=203=20C2=20=E2=80=94=20VFS=20pars?= =?UTF-8?q?es=20file://=20URLs=20as=20local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously parse() only recognised the local:// scheme. A file:///path URL (the standard scheme used by browsers, text editors, and many CLI tools) would be treated as an unknown scheme and fall through to the 'unknown scheme → local' fallback in for_path(), which works but is silent. Now parse() explicitly handles file:// as an alias for local://, making the VFS path normal form 'local://' after parsing. Tests (1 new in vfs::path::tests): - parse_file_scheme_is_alias_for_local Total: 1279 passing (was 1278; +1 new). --- local/recipes/tui/tlc/source/src/vfs/path.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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();