[PR #1084] [MERGED] refactor(utils): dedupe trailing-slash and basePath normalization #1082

Closed
opened 2026-05-06 13:11:53 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/1084
Author: @james-elicx
Created: 5/5/2026
Status: Merged
Merged: 5/5/2026
Merged by: @james-elicx

Base: mainHead: refactor/dedupe-trailing-slash-basepath


📝 Commits (3)

  • e21f24b refactor(utils): dedupe trailing-slash and basePath normalization
  • e3e722d fix(utils): use char-code loop in removeTrailingSlash
  • 6f9ea75 ci: retrigger workflows

📊 Changes

8 files changed (+27 additions, -15 deletions)

View changed files

📝 packages/vinext/src/index.ts (+2 -2)
📝 packages/vinext/src/routing/route-validation.ts (+3 -3)
📝 packages/vinext/src/server/app-page-execution.ts (+2 -1)
📝 packages/vinext/src/server/middleware-matcher.ts (+2 -1)
📝 packages/vinext/src/server/prod-server.ts (+2 -2)
📝 packages/vinext/src/server/request-pipeline.ts (+2 -2)
📝 packages/vinext/src/shims/server.ts (+2 -4)
📝 packages/vinext/src/utils/base-path.ts (+12 -0)

📄 Description

Summary

  • Add removeTrailingSlash helper to packages/vinext/src/utils/base-path.ts that strips trailing slashes while preserving the root / (and collapsing repeated slashes like /a// to /a).
  • Migrate the four pathname.replace(/\/+$/, \"\") sites that match this normalization (index.ts, server/prod-server.ts, server/request-pipeline.ts, server/middleware-matcher.ts, routing/route-validation.ts) to call the helper.
  • Migrate two ad-hoc basePath sites (server/app-page-execution.ts applyAppPageRedirectBasePath, shims/server.ts _stripBasePath) to the existing hasBasePath / stripBasePath helpers.
  • Skipped: cloudflare/tpr.ts (operates on a host string, not a pathname), utils/manifest-paths.ts (intentionally trims to empty for the / base case), and the inlined helpers inside the deploy.ts worker code template (intentionally inlined because that code runs in Cloudflare Workers and cannot import from local source at build time).

Pure refactor; no behaviour change. Follow-up to #1058.

Test plan

  • pnpm vp test run tests/app-router.test.ts tests/pages-router.test.ts (508 tests passed; one unrelated afterAll hook timeout in pages-router allowedDevOrigins suite)
  • pnpm vp test run tests/request-pipeline.test.ts tests/shims.test.ts tests/next-config.test.ts (992 tests passed)
  • pnpm vp test run tests/route-trie.test.ts tests/route-sorting.test.ts tests/app-route-graph.test.ts tests/app-page-execution.test.ts (145 tests passed)
  • pnpm fmt --write
  • pnpm knip (clean)

Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/1084 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 5/5/2026 **Status:** ✅ Merged **Merged:** 5/5/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `refactor/dedupe-trailing-slash-basepath` --- ### 📝 Commits (3) - [`e21f24b`](https://github.com/cloudflare/vinext/commit/e21f24b16877e6b43135be717308b7e198a749b1) refactor(utils): dedupe trailing-slash and basePath normalization - [`e3e722d`](https://github.com/cloudflare/vinext/commit/e3e722d38e24eeb83da3977ab7ebde0c668ad83d) fix(utils): use char-code loop in removeTrailingSlash - [`6f9ea75`](https://github.com/cloudflare/vinext/commit/6f9ea75b14a304cc89a2c37c2e6a6e16566592da) ci: retrigger workflows ### 📊 Changes **8 files changed** (+27 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+2 -2) 📝 `packages/vinext/src/routing/route-validation.ts` (+3 -3) 📝 `packages/vinext/src/server/app-page-execution.ts` (+2 -1) 📝 `packages/vinext/src/server/middleware-matcher.ts` (+2 -1) 📝 `packages/vinext/src/server/prod-server.ts` (+2 -2) 📝 `packages/vinext/src/server/request-pipeline.ts` (+2 -2) 📝 `packages/vinext/src/shims/server.ts` (+2 -4) 📝 `packages/vinext/src/utils/base-path.ts` (+12 -0) </details> ### 📄 Description ## Summary - Add `removeTrailingSlash` helper to `packages/vinext/src/utils/base-path.ts` that strips trailing slashes while preserving the root `/` (and collapsing repeated slashes like `/a//` to `/a`). - Migrate the four `pathname.replace(/\/+$/, \"\")` sites that match this normalization (`index.ts`, `server/prod-server.ts`, `server/request-pipeline.ts`, `server/middleware-matcher.ts`, `routing/route-validation.ts`) to call the helper. - Migrate two ad-hoc basePath sites (`server/app-page-execution.ts` `applyAppPageRedirectBasePath`, `shims/server.ts` `_stripBasePath`) to the existing `hasBasePath` / `stripBasePath` helpers. - Skipped: `cloudflare/tpr.ts` (operates on a host string, not a pathname), `utils/manifest-paths.ts` (intentionally trims to empty for the `/` base case), and the inlined helpers inside the `deploy.ts` worker code template (intentionally inlined because that code runs in Cloudflare Workers and cannot import from local source at build time). Pure refactor; no behaviour change. Follow-up to #1058. ## Test plan - [x] `pnpm vp test run tests/app-router.test.ts tests/pages-router.test.ts` (508 tests passed; one unrelated `afterAll` hook timeout in pages-router allowedDevOrigins suite) - [x] `pnpm vp test run tests/request-pipeline.test.ts tests/shims.test.ts tests/next-config.test.ts` (992 tests passed) - [x] `pnpm vp test run tests/route-trie.test.ts tests/route-sorting.test.ts tests/app-route-graph.test.ts tests/app-page-execution.test.ts` (145 tests passed) - [x] `pnpm fmt --write` - [x] `pnpm knip` (clean) Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:53 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#1082
No description provided.