Skip to content

Commit d7b784c

Browse files
author
InAnYan
committed
Fix joining of paths
1 parent 605eef9 commit d7b784c

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

module/move/assistant/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ serde_with = "3.11.0"
5757
error_tools = "0.17.0"
5858
derive_tools = { version = "0.32.0", features = ["full"] }
5959
regex = { version = "1.10.3" }
60-
itertools = "0.13.0"
6160
serde_yaml = "0.9"
6261

6362
[dev-dependencies]

module/move/assistant/src/agents/path.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ mod private
1212
sync::LazyLock,
1313
};
1414

15-
use itertools::Itertools;
1615
use regex::Regex;
1716

1817
/// Path separator string.
@@ -99,23 +98,24 @@ mod private
9998

10099
/// Creates an owned `Path` by joining a given path to `self`.
101100
///
102-
/// Returns `Err(io::Error)` is the `path` is an absolute path.
101+
/// If path is joined with an absolute path, then this absolute
102+
/// path will be returned.
103103
#[ inline ]
104-
pub fn join( &self, path : &Path ) -> Result< Self, io::Error >
104+
pub fn join( &self, path : &Path ) -> Self
105105
{
106106
if path.is_absolute()
107107
{
108-
Err( io::Error::from( io::ErrorKind::InvalidData ) )
108+
path.clone()
109109
}
110110
else
111111
{
112112
if self.0.ends_with( PATH_SEPARATOR )
113113
{
114-
Ok( Self( format!( "{}{}", self.0, path.0 ) ) )
114+
Self( format!( "{}{}", self.0, path.0 ) )
115115
}
116116
else
117117
{
118-
Ok( Self( format!( "{}::{}", self.0, path.0 ) ) )
118+
Self( format!( "{}::{}", self.0, path.0 ) )
119119
}
120120
}
121121
}

module/move/assistant/tests/inc/agents_tests/path_test.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ fn path_join_relative()
135135

136136
let combined = orig_path.join( &append );
137137

138-
assert!( combined.is_ok() );
139-
assert_eq!( combined.unwrap().inner(), "agent::completion" );
138+
assert_eq!( combined.inner(), "agent::completion" );
140139
}
141140

142141
#[ test ]
@@ -147,7 +146,7 @@ fn path_join_absolute()
147146

148147
let combined = orig_path.join( &append );
149148

150-
assert!( combined.is_err() );
149+
assert_eq!( combined.inner(), "::completion" );
151150
}
152151

153152
#[ test ]
@@ -158,8 +157,7 @@ fn path_join_root()
158157

159158
let combined = orig_path.join( &append );
160159

161-
assert!( combined.is_ok() );
162-
assert_eq!( combined.unwrap().inner(), "::agent" );
160+
assert_eq!( combined.inner(), "::agent" );
163161
}
164162

165163
#[ test ]
@@ -170,8 +168,7 @@ fn path_join_trailing()
170168

171169
let combined = orig_path.join( &append );
172170

173-
assert!( combined.is_ok() );
174-
assert_eq!( combined.unwrap().inner(), "agents::completion" );
171+
assert_eq!( combined.inner(), "agents::completion" );
175172
}
176173

177174
#[ test ]

0 commit comments

Comments
 (0)