MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / statusOfName

Function statusOfName

src/ui-server/api/effects.ts:405–419  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

403};
404
405function statusOfName(raw: string): number | null {
406 let name = raw.replace(/^(?:HttpStatus|HTTPStatus|StatusCodes|StatusCode|http|status|HttpStatusCode|Status|HTTP_|HTTP)[._]?/, '');
407 name = name.replace(/(?:Exception|Error|Response|Result|Async|Http|Status|Code)$/g, '').replace(/^Http(?=[A-Z])/, '');
408 const key = name.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
409 if (key === '') return null;
410 if (/^\d{3}$/.test(key)) return Number(key);
411 const m = /^(?:http)?(\d{3})$/.exec(key) ?? /(?:^|[a-z_])([1-5]\d{2})(?:[a-z_]|$)/.exec(key);
412 if (m) return Number(m[1]);
413 if (STATUS_BY_NAME[key] !== undefined) return STATUS_BY_NAME[key]!;
414 // `UserNotFound`, `InvalidTokenUnauthorized`: the status name ends the class name.
415 for (const [known, code] of Object.entries(STATUS_BY_NAME)) {
416 if (known.length >= 6 && key.endsWith(known)) return code;
417 }
418 return null;
419}
420
421/**
422 * The status code a response site sends, when it is literal: the number in

Callers 2

responseStatusFunction · 0.85
literalStatusFunction · 0.85

Calls 2

NumberInterface · 0.85
execMethod · 0.65

Tested by

no test coverage detected