MCPcopy
hub / github.com/codeaashu/claude-code / prefixMatchesModel

Function prefixMatchesModel

src/utils/model/modelAllowlist.ts:27–32  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

25 * e.g. "claude-opus-4-5" matches "claude-opus-4-5-20251101" but not "claude-opus-4-50".
26 */
27function 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.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected