MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / validateKey

Function validateKey

src/utils/localValidate.ts:26–46  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

24const MAX_KEY_LENGTH = 128
25
26export function validateKey(key: string): void {
27 if (!key) {
28 throw new Error('Empty key')
29 }
30 if (key.length > MAX_KEY_LENGTH) {
31 throw new Error(`Key too long (max ${MAX_KEY_LENGTH})`)
32 }
33 if (!KEY_REGEX.test(key)) {
34 throw new Error(`Invalid key chars: ${JSON.stringify(key)}`)
35 }
36 if (key.startsWith('.')) {
37 throw new Error('Leading dot forbidden')
38 }
39 // M6 fix: match the basename (pre-dot component) so e.g. NUL.txt and
40 // CON.foo are also rejected. On Windows these still alias to the device
41 // file regardless of extension and would silently lose data.
42 const basenameComponent = key.includes('.') ? key.split('.')[0]! : key
43 if (WINDOWS_RESERVED_BASENAME.test(basenameComponent)) {
44 throw new Error(`Windows reserved name: ${key}`)
45 }
46}
47
48/** Returns true iff key would pass validateKey (no throw). Useful for guards. */
49export function isValidKey(key: string): boolean {

Callers 7

isValidKeyFunction · 0.70
getEntryPathFunction · 0.50
setEntryFunction · 0.50
getEntryFunction · 0.50
getEntryBoundedFunction · 0.50
deleteEntryFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected