@@ -231,30 +231,17 @@ func (f *FileSearcher) filterFilesByPathsOrPatterns(statFunc cachedOsStat, patte
231231 rPattern = "^" + pattern + "$"
232232 }
233233 // try matching as go regex pattern
234- relPath , err := filepath .Rel (f .BasePath , file )
235- if err != nil {
236- // This should never happen, if paths are found outside the base path, then something did not occur
237- // correctly.
238- f .Log .Error (fmt .Errorf ("unable to get relative path for file from base path" ),
239- "this should not happen, please file a bug" , "basePath" , f .BasePath , "filePath" , file )
240- continue
241- }
242- relPath = filepath .Join (string (os .PathSeparator ), relPath )
243- f .Log .V (9 ).Info ("using regex to search" , "pattern" , pattern , "relPath" , relPath )
244234 regex , regexErr := regexp .Compile (rPattern )
245- if regexErr == nil && (regex .MatchString (relPath ) || regex .MatchString (filepath .Base (file ))) {
246- f .Log .V (9 ).Info ("regex match" , "pattern" , pattern , "relPath" , relPath )
235+ if regexErr == nil && (regex .MatchString (file ) || regex .MatchString (filepath .Base (file ))) {
247236 patternMatched = true
248237 } else if strings .Contains (pattern , "*" ) || strings .Contains (pattern , "?" ) {
249238 // fallback to filepath.Match for simple patterns
250- m , err := filepath .Match (pattern , relPath )
239+ m , err := filepath .Match (pattern , file )
251240 if err == nil {
252- f .Log .V (9 ).Info ("filepath match" , "pattern" , pattern , "relPath" , relPath )
253241 patternMatched = patternMatched || m
254242 }
255- m , err = filepath .Match (pattern , filepath .Base (relPath ))
243+ m , err = filepath .Match (pattern , filepath .Base (file ))
256244 if err == nil {
257- f .Log .V (9 ).Info ("file name match" , "pattern" , pattern , "relPath" , relPath )
258245 patternMatched = patternMatched || m
259246 }
260247 }
0 commit comments