Skip to content

Commit bd988f2

Browse files
committed
better
1 parent 9c5ceaf commit bd988f2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ pub fn normalize_path(path: Cow<Path>) -> Cow<Path> {
148148
fn should_normalize(path: &Path) -> bool {
149149
for component in path.components() {
150150
match component {
151-
Component::Prefix(..) | Component::CurDir | Component::ParentDir => {
151+
Component::CurDir | Component::ParentDir => {
152152
return true;
153153
}
154-
Component::RootDir | Component::Normal(_) => {
154+
Component::Prefix(..) | Component::RootDir | Component::Normal(_) => {
155155
// ok
156156
}
157157
}
@@ -171,8 +171,11 @@ pub fn normalize_path(path: Cow<Path>) -> Cow<Path> {
171171

172172
if sys_traits::impls::is_windows() {
173173
for window in raw.windows(3) {
174-
// check for both /./ and \.\ on windows
175-
if matches!(window, [b'/', b'.', b'/'] | [b'\\', b'.', b'\\']) {
174+
// check for both /./ and \.\ or any mix of them on windows
175+
if matches!(window[0], b'/' | b'\\')
176+
&& matches!(window[1], b'.')
177+
&& matches!(window[2], b'/' | b'\\')
178+
{
176179
return true;
177180
}
178181
}

0 commit comments

Comments
 (0)