Files
openclaw/src/shared/path-array-index.ts
Peter Steinberger 1e7510ae10 docs: continue inline comment pass (#88849)
Adds broad inline comments and JSDoc for CLI, cron, outbound/channel, plugin SDK, ACP, shared helpers, net policy, and related utility contracts. Proof: git diff --check on latest exact head plus focused cron tests passed; CI had no failing checks observed before merge attempt.
2026-05-31 22:32:28 -04:00

14 lines
580 B
TypeScript

/** Upper bound for config path array indexes to reject impractical sparse writes. */
export const MAX_CONFIG_PATH_ARRAY_INDEX = 100_000;
const CANONICAL_ARRAY_INDEX_SEGMENT = /^(0|[1-9]\d*)$/;
/** Parses a canonical non-negative array index segment used by config and JSON paths. */
export function parseConfigPathArrayIndex(segment: string): number | undefined {
if (!CANONICAL_ARRAY_INDEX_SEGMENT.test(segment)) {
return undefined;
}
const index = Number(segment);
return Number.isSafeInteger(index) && index <= MAX_CONFIG_PATH_ARRAY_INDEX ? index : undefined;
}