[PR #7285] [CLOSED] fix(javascript): decode Next route segments in script URLs #7807

Closed
opened 2026-11-05 01:47:49 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7285
Author: @gongfpp
Created: 10/26/2026
Status: ❌ Closed

Base: main ← Head: fix/next-encoded-script-url-routes-20261027


📝 Commits (1)

  • b18fe86 fix(javascript): decode Next route segments in script URLs

📊 Changes

2 files changed (+54 additions, -7 deletions)

View changed files

📝 src/domain/javascript/javascriptRoutePaths.ts (+16 -7)
📝 src/domain/javascript/javascriptRouteScan.test.ts (+38 -0)

📄 Description

Summary

Fix encoded Next App Router paths read from script URLs. This was reported as an outside-diff finding on #6778 (https://github.com/morluto/rea/pull/6778#issuecomment-6392352464), but also reproduces on upstream main. It is intentionally a separate change so #6778's focused program-scope var guard remains untouched.

Problem and expected behavior

https://example.test/_next/static/chunks/app/blog/%5Bid%5D/page-abc.js previously reported /blog/%5Bid%5D, not /blog/:id: URL.pathname retains percent escapes and Next segment recognition requires literal brackets.

Change and scope

  • At the existing classifyNextAppRoutePath owner, decode URL-derived segments once before interpreting route syntax.
  • Preserve percent spelling of local source filenames, except for Next's established %5F rule.
  • Malformed escapes and decoded slashes are rejected conservatively; double encoding is never decoded twice.
  • Existing parser only; no target execution, process control, network fetch, new provider, schema, CLI option or MCP tool.
  • No separate issue; concrete observation linked to #6778 above. No maintainer approval required for a small existing-boundary correctness fix.

Contract and boundary impact

  • Semantic owner: src/domain/javascript/javascriptRoutePaths.ts; route scan/inventory consume its facts.
  • Corrects URL-derived candidate path values without altering the result schema, source identity, completeness contract, or provenance.
  • Provider/bridge/target formats/cleanup, generated catalogs, package and installation behavior: unchanged.

Expected effects (unchecked items do not establish absence):

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Added tests: URL %5Bid%5D → :id, double-encoded brackets remain literal, source-literal URL vs local path, encoded slash and malformed escape.
  • Baseline: regression test initially failed on unmodified main 3d565fa4 (1 new failure, 258 controls passed); current main 0d1a454e still contained the same path classifier.
  • Fixed representative output: URL chunk → /blog/:id, local path app/blog/%5Bid%5D/page.tsx → /blog/%5Bid%5D.
  • Applicable parser/boundary tests, malformed inputs and source identity are covered. No new lifecycle behavior.
  • Real compiled public CLI/MCP scenario not run; source-level regression is not an end-to-end provider claim.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • On latest upstream main 0d1a454e + this commit: 284/284 passed in javascriptRouteScan.test.ts, javascriptRouteInventory.test.ts, javascriptRouteResultBudget.test.ts.
  • node scripts/run-typescript.mjs --noEmit: passed.
  • oxfmt --check on changed files: passed before rebase (same file content).
  • git diff --check upstream/main...HEAD: passed.
  • Environment: Windows Node 24.22.0; repo .nvmrc requests 24.22.1. Linux CI and browser/provider workflows remain unverified.

Compatibility, safety, and release

No migration, no new authority, no target mutation, no credential/remote interaction, no package/release metadata impact. Runtime behavior outside the URL-derived Next path classifier is unchanged.

Author readiness

Human owner: @gongfpp

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Problem/scope/issue relation checked.
  • Required validation and remaining gaps reviewed.
  • Real public CLI/MCP output confirmed where applicable.
  • Human owner reviewed and approved the final diff.

🔄 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/morluto/rea/pull/7285 **Author:** [@gongfpp](https://github.com/gongfpp) **Created:** 10/26/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/next-encoded-script-url-routes-20261027` --- ### 📝 Commits (1) - [`b18fe86`](https://github.com/morluto/rea/commit/b18fe865ba75ce83d8baec994815c106b244c78d) fix(javascript): decode Next route segments in script URLs ### 📊 Changes **2 files changed** (+54 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptRoutePaths.ts` (+16 -7) 📝 `src/domain/javascript/javascriptRouteScan.test.ts` (+38 -0) </details> ### 📄 Description ## Summary Fix encoded Next App Router paths read from **script URLs**. This was reported as an *outside-diff* finding on #6778 (https://github.com/morluto/rea/pull/6778#issuecomment-6392352464), but also reproduces on upstream main. It is intentionally a **separate** change so #6778's focused program-scope `var` guard remains untouched. ## Problem and expected behavior `https://example.test/_next/static/chunks/app/blog/%5Bid%5D/page-abc.js` previously reported `/blog/%5Bid%5D`, not `/blog/:id`: `URL.pathname` retains percent escapes and Next segment recognition requires literal brackets. ## Change and scope - At the existing `classifyNextAppRoutePath` owner, decode URL-derived *segments* once before interpreting route syntax. - Preserve percent spelling of local source filenames, except for Next's established `%5F` rule. - Malformed escapes and decoded slashes are rejected conservatively; double encoding is never decoded twice. - Existing parser only; no target execution, process control, network fetch, new provider, schema, CLI option or MCP tool. - No separate issue; concrete observation linked to #6778 above. No maintainer approval required for a small existing-boundary correctness fix. ## Contract and boundary impact - Semantic owner: `src/domain/javascript/javascriptRoutePaths.ts`; route scan/inventory consume its facts. - Corrects URL-derived candidate path values without altering the result schema, source identity, completeness contract, or provenance. - Provider/bridge/target formats/cleanup, generated catalogs, package and installation behavior: unchanged. Expected effects (unchecked items do not establish absence): - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Added tests: URL `%5Bid%5D` → `:id`, double-encoded brackets remain literal, source-literal URL vs local path, encoded slash and malformed escape. - Baseline: regression test initially failed on unmodified main `3d565fa4` (1 new failure, 258 controls passed); current main `0d1a454e` still contained the same path classifier. - Fixed representative output: URL chunk → `/blog/:id`, local path `app/blog/%5Bid%5D/page.tsx` → `/blog/%5Bid%5D`. - Applicable parser/boundary tests, malformed inputs and source identity are covered. No new lifecycle behavior. - Real compiled public CLI/MCP scenario not run; source-level regression is not an end-to-end provider claim. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - On latest upstream main `0d1a454e` + this commit: 284/284 passed in `javascriptRouteScan.test.ts`, `javascriptRouteInventory.test.ts`, `javascriptRouteResultBudget.test.ts`. - `node scripts/run-typescript.mjs --noEmit`: passed. - `oxfmt --check` on changed files: passed before rebase (same file content). - `git diff --check upstream/main...HEAD`: passed. - Environment: Windows Node `24.22.0`; repo `.nvmrc` requests `24.22.1`. Linux CI and browser/provider workflows remain unverified. ## Compatibility, safety, and release No migration, no new authority, no target mutation, no credential/remote interaction, no package/release metadata impact. Runtime behavior outside the URL-derived Next path classifier is unchanged. ## Author readiness Human owner: @gongfpp - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [ ] Problem/scope/issue relation checked. - [ ] Required validation and remaining gaps reviewed. - [ ] Real public CLI/MCP output confirmed where applicable. - [ ] Human owner reviewed and approved the final diff. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-05 01:47:49 +00: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
morluto/rea#7807
No description provided.