[PR #1073] [MERGED] refactor(server): dedupe .rsc suffix stripping #1070

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

📋 Pull Request Information

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

Base: mainHead: refactor/dedupe-rsc-suffix-strip


📝 Commits (1)

  • e0e2c00 refactor(server): dedupe .rsc suffix stripping

📊 Changes

4 files changed (+15 additions, -4 deletions)

View changed files

📝 packages/vinext/src/server/app-browser-entry.ts (+3 -2)
📝 packages/vinext/src/server/app-rsc-cache-busting.ts (+8 -0)
📝 packages/vinext/src/server/app-rsc-handler.ts (+2 -1)
📝 packages/vinext/src/server/app-rsc-request-normalization.ts (+2 -1)

📄 Description

Summary

  • Extract the repeated pathname.replace(/\.rsc$/, "") and equivalent slice-based suffix removal into a single stripRscSuffix(pathname: string): string helper.
  • Pure refactor — semantics preserved at every call site (each input had at most one trailing .rsc to strip; both regex and slice forms produce identical output for that shape).
  • Follow-up to #1058.

Files changed

  • packages/vinext/src/server/app-rsc-cache-busting.ts — adds stripRscSuffix (slice-based; chosen as the home since it's already imported by every call site and has no server-only dependencies).
  • packages/vinext/src/server/app-rsc-request-normalization.ts — replaces pathname.replace(/\.rsc$/, "") for cleanPathname.
  • packages/vinext/src/server/app-browser-entry.ts — replaces two replace(/\.rsc$/, "") call sites.
  • packages/vinext/src/server/app-rsc-handler.ts — replaces the inline endsWith(".rsc") ? slice(0,-4) : pathname ternary for redirectPathname.

Test plan

  • pnpm vp test run tests/app-router.test.ts — 308 passed
  • pnpm fmt --write on touched files
  • pnpm knip — clean

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com


🔄 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/1073 **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-rsc-suffix-strip` --- ### 📝 Commits (1) - [`e0e2c00`](https://github.com/cloudflare/vinext/commit/e0e2c001d863b294885cf582e4b832f17da94e98) refactor(server): dedupe .rsc suffix stripping ### 📊 Changes **4 files changed** (+15 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/app-browser-entry.ts` (+3 -2) 📝 `packages/vinext/src/server/app-rsc-cache-busting.ts` (+8 -0) 📝 `packages/vinext/src/server/app-rsc-handler.ts` (+2 -1) 📝 `packages/vinext/src/server/app-rsc-request-normalization.ts` (+2 -1) </details> ### 📄 Description ## Summary - Extract the repeated `pathname.replace(/\.rsc$/, "")` and equivalent slice-based suffix removal into a single `stripRscSuffix(pathname: string): string` helper. - Pure refactor — semantics preserved at every call site (each input had at most one trailing `.rsc` to strip; both regex and slice forms produce identical output for that shape). - Follow-up to #1058. ## Files changed - `packages/vinext/src/server/app-rsc-cache-busting.ts` — adds `stripRscSuffix` (slice-based; chosen as the home since it's already imported by every call site and has no server-only dependencies). - `packages/vinext/src/server/app-rsc-request-normalization.ts` — replaces `pathname.replace(/\.rsc$/, "")` for `cleanPathname`. - `packages/vinext/src/server/app-browser-entry.ts` — replaces two `replace(/\.rsc$/, "")` call sites. - `packages/vinext/src/server/app-rsc-handler.ts` — replaces the inline `endsWith(".rsc") ? slice(0,-4) : pathname` ternary for `redirectPathname`. ## Test plan - [x] `pnpm vp test run tests/app-router.test.ts` — 308 passed - [x] `pnpm fmt --write` on touched files - [x] `pnpm knip` — clean Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --- <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:50 +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#1070
No description provided.