fix: preserve query string on automatic redirects
Summary
- preserve the original query string for serve-handler's automatic redirects
- limit the behavior change to
cleanUrlsandtrailingSlashredirects - 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-viewscorepack yarn jest test/integration.test.js --runInBand --forceExit
Fixes #178
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-lockfilecorepack yarn run build-viewscorepack yarn test
Current result: all tests passed, including the query-preservation coverage for both cleanUrls and trailingSlash redirects.