* Check if a model name starts with a prefix at a segment boundary. * The prefix must match up to the end of the name or a "-" separator. * e.g. "claude-opus-4-5" matches "claude-opus-4-5-20251101" but not "claude-opus-4-50".
(modelName: string, prefix: string)
| 25 | * e.g. "claude-opus-4-5" matches "claude-opus-4-5-20251101" but not "claude-opus-4-50". |
| 26 | */ |
| 27 | function prefixMatchesModel(modelName: string, prefix: string): boolean { |
| 28 | if (!modelName.startsWith(prefix)) { |
| 29 | return false |
| 30 | } |
| 31 | return modelName.length === prefix.length || modelName[prefix.length] === '-' |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Check if a model matches a version-prefix entry in the allowlist. |
no outgoing calls
no test coverage detected