mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
path-uri: clarify host-native path conversion (#29501)
## Why Downstream refactors are producing confusing code with this functionality having a very generic name. Encoding the specific conversion approach in the method name makes it clearer. ## What Rename `PathUri::from_path` to `PathUri::from_host_native_path` and update its Rust call sites.
This commit is contained in:
@@ -121,7 +121,7 @@ impl PathUri {
|
||||
/// Relative paths are reported as invalid input. Absolute paths without a
|
||||
/// valid URI representation use the fallback documented on
|
||||
/// [`Self::from_abs_path`].
|
||||
pub fn from_path(path: impl AsRef<Path>) -> io::Result<Self> {
|
||||
pub fn from_host_native_path(path: impl AsRef<Path>) -> io::Result<Self> {
|
||||
let path = AbsolutePathBuf::from_absolute_path_checked(path)
|
||||
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?;
|
||||
Ok(Self::from_abs_path(&path))
|
||||
|
||||
@@ -423,7 +423,8 @@ fn path_uri_deserializes_legacy_absolute_paths() {
|
||||
|
||||
#[test]
|
||||
fn path_uri_rejects_relative_native_paths() {
|
||||
let error = PathUri::from_path("src/lib.rs").expect_err("relative path should be rejected");
|
||||
let error =
|
||||
PathUri::from_host_native_path("src/lib.rs").expect_err("relative path should be rejected");
|
||||
|
||||
assert_eq!(error.kind(), io::ErrorKind::InvalidInput);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user