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

Function parsePortSuffix

src/ui-server/security.ts:146–153  ·  view source on GitHub ↗

* Parse the `:1234` tail of a `Host` header. * * @returns the port, `undefined` for an empty suffix, or `null` when the suffix * is present but not a plain port number.

(suffix: string)

Source from the content-addressed store, hash-verified

144 * is present but not a plain port number.
145 */
146function parsePortSuffix(suffix: string): number | undefined | null {
147 if (suffix === '') return undefined;
148 if (!suffix.startsWith(':')) return null;
149 const digits = suffix.slice(1);
150 if (!/^\d{1,5}$/.test(digits)) return null;
151 const port = Number(digits);
152 return port >= 0 && port <= 65535 ? port : null;
153}
154
155/**
156 * Whether a request's `Host` header names this loopback server.

Callers 1

splitHostPortFunction · 0.85

Calls 1

NumberInterface · 0.85

Tested by

no test coverage detected