@@ -128,6 +128,8 @@ func (fsf FileSystemFinder) findOne(pathRoot string, seenMap map[string]struct{}
128128 if ! dirEntry .IsDir () {
129129 // filepath.Ext() returns the extension name with a dot so it
130130 // needs to be removed.
131+
132+ walkFileName := filepath .Base (path )
131133 walkFileExtension := strings .TrimPrefix (filepath .Ext (path ), "." )
132134 extensionLowerCase := strings .ToLower (walkFileExtension )
133135
@@ -136,20 +138,25 @@ func (fsf FileSystemFinder) findOne(pathRoot string, seenMap map[string]struct{}
136138 }
137139
138140 for _ , fileType := range fsf .FileTypes {
139- if _ , isMatched := fileType .Extensions [extensionLowerCase ]; isMatched {
140- absPath , err := filepath .Abs (path )
141- if err != nil {
142- return err
143- }
144-
145- if _ , seen := seenMap [absPath ]; ! seen {
146- fileMetadata := FileMetadata {dirEntry .Name (), absPath , fileType }
147- matchingFiles = append (matchingFiles , fileMetadata )
148- seenMap [absPath ] = struct {}{}
149- }
150-
151- return nil
141+ _ , isKnownFile := fileType .KnownFiles [walkFileName ]
142+ _ , hasExtension := fileType .Extensions [extensionLowerCase ]
143+
144+ if ! isKnownFile && ! hasExtension {
145+ continue
146+ }
147+
148+ absPath , err := filepath .Abs (path )
149+ if err != nil {
150+ return err
152151 }
152+
153+ if _ , seen := seenMap [absPath ]; ! seen {
154+ fileMetadata := FileMetadata {dirEntry .Name (), absPath , fileType }
155+ matchingFiles = append (matchingFiles , fileMetadata )
156+ seenMap [absPath ] = struct {}{}
157+ }
158+
159+ return nil
153160 }
154161 fsf .ExcludeFileTypes [extensionLowerCase ] = struct {}{}
155162 }
0 commit comments