* Check if a model matches a version-prefix entry in the allowlist. * Supports shorthand like "opus-4-5" (mapped to "claude-opus-4-5") and * full prefixes like "claude-opus-4-5". Resolves input aliases before matching.
(model: string, entry: string)
| 37 | * full prefixes like "claude-opus-4-5". Resolves input aliases before matching. |
| 38 | */ |
| 39 | function modelMatchesVersionPrefix(model: string, entry: string): boolean { |
| 40 | // Resolve the input model to a full name if it's an alias |
| 41 | const resolvedModel = isModelAlias(model) |
| 42 | ? parseUserSpecifiedModel(model).toLowerCase() |
| 43 | : model |
| 44 | |
| 45 | // Try the entry as-is (e.g. "claude-opus-4-5") |
| 46 | if (prefixMatchesModel(resolvedModel, entry)) { |
| 47 | return true |
| 48 | } |
| 49 | // Try with "claude-" prefix (e.g. "opus-4-5" → "claude-opus-4-5") |
| 50 | if ( |
| 51 | !entry.startsWith('claude-') && |
| 52 | prefixMatchesModel(resolvedModel, `claude-${entry}`) |
| 53 | ) { |
| 54 | return true |
| 55 | } |
| 56 | return false |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Check if a family alias is narrowed by more specific entries in the allowlist. |
no test coverage detected