MCPcopy
hub / github.com/coder/mux / normalizePublicBasePath

Function normalizePublicBasePath

src/node/orpc/server.ts:471–486  ·  view source on GitHub ↗
(value: string | null | undefined)

Source from the content-addressed store, hash-verified

469}
470
471function normalizePublicBasePath(value: string | null | undefined): string | null {
472 if (!value) {
473 return null;
474 }
475
476 const trimmed = value.trim();
477 if (!trimmed || trimmed.startsWith("//")) {
478 return null;
479 }
480
481 const withLeadingSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
482 const withoutTrailingSlash =
483 withLeadingSlash === "/" ? withLeadingSlash : withLeadingSlash.replace(/\/+$/, "");
484
485 return isValidUrlPathname(withoutTrailingSlash) ? withoutTrailingSlash : null;
486}
487
488function parsePathnameFromRequestValue(value: string | null | undefined): string | null {
489 if (!value) {

Callers 2

getRequestPublicBasePathFunction · 0.85
joinPublicBasePathFunction · 0.85

Calls 1

isValidUrlPathnameFunction · 0.85

Tested by

no test coverage detected