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

Function safeNextPath

telemetry-dashboard/src/index.ts:126–130  ·  view source on GitHub ↗

* Only same-origin absolute paths survive, so `?next=` can never become an open * redirect. `//evil.example` and `/\evil.example` are protocol-relative URLs in * a browser, not paths — hence the second character check.

(candidate: string | null)

Source from the content-addressed store, hash-verified

124 * a browser, not paths — hence the second character check.
125 */
126function safeNextPath(candidate: string | null): string {
127 if (!candidate || !candidate.startsWith('/')) return '/';
128 if (candidate.startsWith('//') || candidate.startsWith('/\\')) return '/';
129 return candidate;
130}
131
132function loginRedirect(url: URL): Response {
133 const next = `${url.pathname}${url.search}`;

Callers 2

handleLoginPageFunction · 0.85
handleLoginSubmitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected