@@ -109,21 +109,13 @@ impl CrateScope {
109
109
}
110
110
111
111
pub fn matches ( & self , crate_name : & str ) -> bool {
112
- let canonicalize = |name : & str | name. replace ( '-' , "_" ) ;
113
-
114
112
if self . pattern == "*" {
115
113
return true ;
116
114
}
117
115
118
116
return match self . pattern . strip_suffix ( '*' ) {
119
- Some ( prefix) => {
120
- crate_name. starts_with ( prefix)
121
- || canonicalize ( crate_name) . starts_with ( & canonicalize ( prefix) )
122
- }
123
- None => {
124
- crate_name == self . pattern
125
- || canonicalize ( crate_name) == canonicalize ( & self . pattern )
126
- }
117
+ Some ( prefix) => crate_name. starts_with ( prefix) ,
118
+ None => crate_name == self . pattern ,
127
119
} ;
128
120
}
129
121
}
@@ -174,12 +166,12 @@ mod tests {
174
166
assert ! ( !scope( "foo" ) . matches( "foo-bar" ) ) ;
175
167
assert ! ( !scope( "foo" ) . matches( "foo_bar" ) ) ;
176
168
assert ! ( scope( "foo-bar" ) . matches( "foo-bar" ) ) ;
177
- assert ! ( scope( "foo-bar" ) . matches( "foo_bar" ) ) ;
178
- assert ! ( scope( "foo_bar" ) . matches( "foo-bar" ) ) ;
169
+ assert ! ( ! scope( "foo-bar" ) . matches( "foo_bar" ) ) ;
170
+ assert ! ( ! scope( "foo_bar" ) . matches( "foo-bar" ) ) ;
179
171
assert ! ( scope( "foo_bar" ) . matches( "foo_bar" ) ) ;
180
172
assert ! ( scope( "foo-*" ) . matches( "foo-bar" ) ) ;
181
- assert ! ( scope( "foo-*" ) . matches( "foo_bar" ) ) ;
182
- assert ! ( scope( "foo_*" ) . matches( "foo-bar" ) ) ;
173
+ assert ! ( ! scope( "foo-*" ) . matches( "foo_bar" ) ) ;
174
+ assert ! ( ! scope( "foo_*" ) . matches( "foo-bar" ) ) ;
183
175
assert ! ( scope( "foo_*" ) . matches( "foo_bar" ) ) ;
184
176
}
185
177
}
0 commit comments