serve-handler icon indicating copy to clipboard operation
serve-handler copied to clipboard

fix: preserve query string on automatic redirects

Open WilliamK112 opened this issue 7 months ago • 1 comments

Summary

  • preserve the original query string for serve-handler's automatic redirects
  • limit the behavior change to cleanUrls and trailingSlash redirects
  • add integration coverage for both redirect paths

Problem

Requests such as /directory/clean-file.html?foo=bar currently redirect to /directory/clean-file, dropping the original query string. The same thing happens for automatic trailing slash redirects.

Scope

This patch keeps the change narrow on purpose: it preserves the query string only for redirects generated internally by cleanUrls and trailingSlash. It does not change the behavior of user-configured redirects.

Testing

  • corepack yarn build-views
  • corepack yarn jest test/integration.test.js --runInBand --forceExit

Fixes #178

WilliamK112 avatar Apr 25 '26 08:04 WilliamK112

Revalidated this on current main today. The behavior from issue #178 still reproduces without this patch, and this PR still fixes it with a narrow diff limited to src/index.js and the integration test coverage.

Validation rerun locally:

  • corepack yarn install --network-timeout 1000000 --frozen-lockfile
  • corepack yarn run build-views
  • corepack yarn test

Current result: all tests passed, including the query-preservation coverage for both cleanUrls and trailingSlash redirects.

WilliamK112 avatar Jun 03 '26 19:06 WilliamK112