Skip to content

Commit 09fb02e

Browse files
committed
refactor: inline getRoutePathnameForBaseHref wrapper
The new helper added in #3195 was a 1-line shim around `getPathnameFromRequestUrl(req.url)` used in only two adjacent functions (`shouldInjectSlashlessRootRedirect` and `getPublicBaseHref`). The existing `getPathnameFromRequestUrl` already conveys the intent, and the two callsites read clearly without the extra layer. Behavior-preserving: each callsite continues to compute the same pathname (or null) it did before. All 52 tests in src/node/orpc/server.test.ts continue to pass.
1 parent 50b2b25 commit 09fb02e

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/node/orpc/server.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,6 @@ function getDirectAppProxyHandlerPrefix(
593593
: routePrefix;
594594
}
595595

596-
function getRoutePathnameForBaseHref(req: express.Request): string | null {
597-
return getPathnameFromRequestUrl(req.url);
598-
}
599-
600596
function getRelativeBaseHrefFromRoutePathname(routePathname: string): string {
601597
const pathname = routePathname.startsWith("/") ? routePathname : `/${routePathname}`;
602598
const segments = pathname.split("/").slice(1);
@@ -605,7 +601,7 @@ function getRelativeBaseHrefFromRoutePathname(routePathname: string): string {
605601
}
606602

607603
function shouldInjectSlashlessRootRedirect(req: express.Request): boolean {
608-
return getRoutePathnameForBaseHref(req) === "/";
604+
return getPathnameFromRequestUrl(req.url) === "/";
609605
}
610606

611607
function getPublicBaseHref(req: express.Request, res: express.Response): string {
@@ -617,7 +613,7 @@ function getPublicBaseHref(req: express.Request, res: express.Response): string
617613
// User rationale: when a reverse proxy strips the app prefix without forwarding
618614
// headers, a relative climb still lets the browser resolve assets from the
619615
// public app root. Root-hosted deep links resolve correctly too.
620-
return getRelativeBaseHrefFromRoutePathname(getRoutePathnameForBaseHref(req) ?? "/");
616+
return getRelativeBaseHrefFromRoutePathname(getPathnameFromRequestUrl(req.url) ?? "/");
621617
}
622618

623619
function getPublicAppRootPath(req: express.Request, res: express.Response): string {

0 commit comments

Comments
 (0)