(models []*ModelInfo, prefix string, forceModelPrefix bool)
| 2355 | } |
| 2356 | |
| 2357 | func applyModelPrefixes(models []*ModelInfo, prefix string, forceModelPrefix bool) []*ModelInfo { |
| 2358 | trimmedPrefix := strings.TrimSpace(prefix) |
| 2359 | if trimmedPrefix == "" || len(models) == 0 { |
| 2360 | return models |
| 2361 | } |
| 2362 | |
| 2363 | out := make([]*ModelInfo, 0, len(models)*2) |
| 2364 | seen := make(map[string]struct{}, len(models)*2) |
| 2365 | |
| 2366 | addModel := func(model *ModelInfo) { |
| 2367 | if model == nil { |
| 2368 | return |
| 2369 | } |
| 2370 | id := strings.TrimSpace(model.ID) |
| 2371 | if id == "" { |
| 2372 | return |
| 2373 | } |
| 2374 | if _, exists := seen[id]; exists { |
| 2375 | return |
| 2376 | } |
| 2377 | seen[id] = struct{}{} |
| 2378 | out = append(out, model) |
| 2379 | } |
| 2380 | |
| 2381 | for _, model := range models { |
| 2382 | if model == nil { |
| 2383 | continue |
| 2384 | } |
| 2385 | baseID := strings.TrimSpace(model.ID) |
| 2386 | if baseID == "" { |
| 2387 | continue |
| 2388 | } |
| 2389 | if !forceModelPrefix || trimmedPrefix == baseID { |
| 2390 | addModel(model) |
| 2391 | } |
| 2392 | clone := *model |
| 2393 | clone.ID = trimmedPrefix + "/" + baseID |
| 2394 | addModel(&clone) |
| 2395 | } |
| 2396 | return out |
| 2397 | } |
| 2398 | |
| 2399 | // matchWildcard performs case-insensitive wildcard matching where '*' matches any substring. |
| 2400 | func matchWildcard(pattern, value string) bool { |
no outgoing calls
no test coverage detected