Show More
@@ -159,26 +159,20 b' fn _build_single_regex(' | |||
|
159 | 159 | if pattern[0] == b'^' { |
|
160 | 160 | return pattern.to_owned(); |
|
161 | 161 | } |
|
162 | let mut res = b".*".to_vec(); | |
|
163 | res.extend(pattern); | |
|
164 | res | |
|
162 | [b".*", pattern].concat() | |
|
165 | 163 | } |
|
166 | 164 | PatternSyntax::Path | PatternSyntax::RelPath => { |
|
167 | 165 | if pattern == b"." { |
|
168 | 166 | return vec![]; |
|
169 | 167 | } |
|
170 | let mut pattern = escape_pattern(pattern); | |
|
171 | pattern.extend(b"(?:/|$)"); | |
|
172 | pattern | |
|
168 | [escape_pattern(pattern).as_slice(), b"(?:/|$)"].concat() | |
|
173 | 169 | } |
|
174 | 170 | PatternSyntax::RootFiles => { |
|
175 | 171 | let mut res = if pattern == b"." { |
|
176 | 172 | vec![] |
|
177 | 173 | } else { |
|
178 | 174 | // Pattern is a directory name. |
|
179 | let mut as_vec: Vec<u8> = escape_pattern(pattern); | |
|
180 | as_vec.push(b'/'); | |
|
181 | as_vec | |
|
175 | [escape_pattern(pattern).as_slice(), b"/"].concat() | |
|
182 | 176 | }; |
|
183 | 177 | |
|
184 | 178 | // Anything after the pattern must be a non-directory. |
@@ -186,23 +180,15 b' fn _build_single_regex(' | |||
|
186 | 180 | res |
|
187 | 181 | } |
|
188 | 182 | PatternSyntax::RelGlob => { |
|
189 | let mut res: Vec<u8> = vec![]; | |
|
190 | 183 | let glob_re = glob_to_re(pattern); |
|
191 | 184 | if let Some(rest) = glob_re.drop_prefix(b"[^/]*") { |
|
192 | res.extend(b".*"); | |
|
193 | res.extend(rest); | |
|
185 | [b".*", rest, globsuffix].concat() | |
|
194 | 186 | } else { |
|
195 | res.extend(b"(?:|.*/)"); | |
|
196 | res.extend(glob_re); | |
|
187 | [b"(?:|.*/)", glob_re.as_slice(), globsuffix].concat() | |
|
197 | 188 | } |
|
198 | res.extend(globsuffix.iter()); | |
|
199 | res | |
|
200 | 189 | } |
|
201 | 190 | PatternSyntax::Glob | PatternSyntax::RootGlob => { |
|
202 | let mut res: Vec<u8> = vec![]; | |
|
203 | res.extend(glob_to_re(pattern)); | |
|
204 | res.extend(globsuffix.iter()); | |
|
205 | res | |
|
191 | [glob_to_re(pattern).as_slice(), globsuffix].concat() | |
|
206 | 192 | } |
|
207 | 193 | } |
|
208 | 194 | } |
General Comments 0
You need to be logged in to leave comments.
Login now