diff --git a/svc/routes/product_images.go b/svc/routes/product_images.go index 097cff3..cd35e80 100644 --- a/svc/routes/product_images.go +++ b/svc/routes/product_images.go @@ -64,6 +64,19 @@ func imageFileHasDim3Pattern(fileName string) bool { return false } +func firstThreeDigitToken(tokens []string) string { + for _, t := range tokens { + base := t + if idx := strings.Index(base, "_"); idx >= 0 { + base = base[:idx] + } + if len(base) == 3 && isAllDigits(base) { + return base + } + } + return "" +} + func imageFileMatches(fileName, dim1, dim3 string) bool { dim1 = strings.ToUpper(strings.TrimSpace(dim1)) dim3 = strings.ToUpper(strings.TrimSpace(dim3)) @@ -99,6 +112,15 @@ func imageFileMatches(fileName, dim1, dim3 string) bool { return false } + // dim1 filtresi varsa, dosya adindaki primary renk token'i farkliysa eslesme sayma. + // Ornek: "017--002_1" dosyasi dim1=002 icin degil, primary=017 oldugu icin dislanmali. + if dim1 != "" { + primary := firstThreeDigitToken(tokens) + if primary != "" && primary != dim1 { + return false + } + } + return hasToken(dim1) && hasToken(dim3) }