Skip to content

Commit 21e382c

Browse files
authored
fix: ensure the file type match pattern includes folder case (#265)
Signed-off-by: chlins <[email protected]>
1 parent a4dc545 commit 21e382c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pkg/modelfile/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func IsFileType(filename string, patterns []string) bool {
434434
lowerFilename := strings.ToLower(filename)
435435
for _, pattern := range patterns {
436436
// Convert pattern to lowercase for case-insensitive comparison
437-
matched, err := filepath.Match(strings.ToLower(pattern), lowerFilename)
437+
matched, err := filepath.Match(strings.ToLower(pattern), filepath.Base(lowerFilename))
438438
if err == nil && matched {
439439
return true
440440
}

pkg/modelfile/constants_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ func TestIsFileType(t *testing.T) {
2020
{"script.py", []string{"*.py", "*.sh"}, true},
2121
{"script.sh", []string{"*.py", "*.sh"}, true},
2222
{"script.bash", []string{"*.py", "*.sh"}, false},
23+
{"folder/config.json", []string{"*.json", "*.yaml"}, true},
24+
{"FOLDER/config.json", []string{"*.json", "*.yaml"}, true},
25+
{"folder/CONFIG.JSON", []string{"*.json", "*.yaml"}, true},
26+
{"folder\\config.json", []string{"*.json", "*.yaml"}, true},
2327
}
2428

2529
assert := assert.New(t)

0 commit comments

Comments
 (0)