Skip to content

Commit f0be996

Browse files
authored
Update utf8_paths
1 parent 4c35582 commit f0be996

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ where
5757
} else {
5858
let mut ita = path.components();
5959
let mut itb = base.components();
60+
let mut comps: Vec<Component> = vec![];
6061

6162
// ./foo and foo are the same
6263
if let Some(Component::CurDir) = ita.clone().next() {
@@ -65,7 +66,7 @@ where
6566
if let Some(Component::CurDir) = itb.clone().next() {
6667
itb.next();
6768
}
68-
let mut comps: Vec<Component> = vec![];
69+
6970
loop {
7071
match (ita.next(), itb.next()) {
7172
(None, None) => break,
@@ -144,6 +145,15 @@ mod utf8_paths {
144145
let mut ita = path.components();
145146
let mut itb = base.components();
146147
let mut comps: Vec<Utf8Component> = vec![];
148+
149+
// ./foo and foo are the same
150+
if let Some(Utf8Component::CurDir) = ita.clone().next() {
151+
ita.next();
152+
}
153+
if let Some(Utf8Component::CurDir) = itb.clone().next() {
154+
itb.next();
155+
}
156+
147157
loop {
148158
match (ita.next(), itb.next()) {
149159
(None, None) => break,
@@ -255,7 +265,7 @@ mod tests {
255265
assert_diff_paths(".", "foo", Some("../."));
256266
assert_diff_paths("foo", ".", Some("foo"));
257267
assert_diff_paths("/foo", "/.", Some("foo"));
258-
268+
259269
assert_diff_paths("./foo/bar/baz", "foo", Some("bar/baz"));
260270
assert_diff_paths("foo/bar/baz", "./foo", Some("bar/baz"));
261271
assert_diff_paths("./foo/bar/baz", "./foo", Some("bar/baz"));

0 commit comments

Comments
 (0)