File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -3109,17 +3109,25 @@ impl Hash for Path {
3109
3109
bytes_hashed += to_hash. len ( ) ;
3110
3110
}
3111
3111
3112
- // skip over separator and optionally a following CurDir item
3112
+ // Skip over separators and, optionally, a following CurDir item
3113
3113
// since components() would normalize these away.
3114
3114
component_start = i + 1 ;
3115
3115
3116
3116
let tail = & bytes[ component_start..] ;
3117
3117
3118
3118
if !verbatim {
3119
3119
component_start += match tail {
3120
+ [ ] => 0 , // Do not hash a trailing separator
3120
3121
[ b'.' ] => 1 ,
3121
3122
[ b'.' , sep @ _, ..] if is_sep_byte ( * sep) => 1 ,
3122
- _ => 0 ,
3123
+ _ => {
3124
+ // Hash the first separator so we can distinguish between
3125
+ // `foo/bar` and `foobar`
3126
+ let to_hash = & [ b'/' as u8 ] ;
3127
+ h. write ( to_hash) ;
3128
+ bytes_hashed += to_hash. len ( ) ;
3129
+ 0
3130
+ }
3123
3131
} ;
3124
3132
}
3125
3133
}
You can’t perform that action at this time.
0 commit comments