Skip to content

fix: hide internal rest param from prefixed middleware#235

Open
raashish1601 wants to merge 1 commit into
koajs:masterfrom
raashish1601:codex/drop-internal-rest-param
Open

fix: hide internal rest param from prefixed middleware#235
raashish1601 wants to merge 1 commit into
koajs:masterfrom
raashish1601:codex/drop-internal-rest-param

Conversation

@raashish1601
Copy link
Copy Markdown

Fixes #233.

Summary

  • prevent the generated {/*rest} wildcard used for prefixed router middleware from being copied into ctx.params
  • keep prefix params available to both middleware and route handlers
  • add a regression test for a parameterized prefix with global middleware and a child route

Validation

  • npm run ts:check
  • npm run ts:check:test
  • npm run lint
  • npm run build
  • npm run format:check
  • git diff --check
  • $env:TS_NODE_PROJECT='tsconfig.ts-node.json'; node --require ts-node/register --test --test-name-pattern "does not expose internal rest param" test/router.test.ts
  • $env:TS_NODE_PROJECT='tsconfig.ts-node.json'; node --require ts-node/register --test --test-name-pattern "Router#prefix" test/router.test.ts
  • $env:TS_NODE_PROJECT='tsconfig.ts-node.json'; node --require ts-node/register --test test/router.test.ts
  • $env:TS_NODE_PROJECT='tsconfig.ts-node.json'; node --require ts-node/register --test test/layer.test.ts
  • $env:TS_NODE_PROJECT='tsconfig.ts-node.json'; node --require ts-node/register --test test/utils/*.test.ts

npm run test:core / the pre-commit test:all command could not run directly on this Windows shell because the package scripts use POSIX-style TS_NODE_PROJECT=... environment assignment. Running the equivalent PowerShell commands above passed for the touched test areas; the full command additionally hit existing Windows shelling failures in test/index.test.ts after npm run build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] Extranous rest key added to ctx.params when middleware used with prefixed router

1 participant