Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/router-core/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1795,11 +1795,21 @@ export class RouterCore<
})

if (foundMask) {
const { from: _from, ...maskProps } = foundMask
const { from: _from, params: maskParams, ...maskProps } = foundMask

// If mask has a params function, call it with the matched params as context
// Otherwise, use the matched params or the provided params value
const nextParams =
maskParams === false || maskParams === null
? {}
: (maskParams ?? true) === true
? params
: Object.assign(params, functionalUpdate(maskParams, params))

maskedDest = {
from: opts.from,
...maskProps,
params,
params: nextParams,
Comment on lines +1798 to +1812
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Logic correctly applies custom mask params to resolve issue #5755.

The implementation properly extracts and applies maskParams from the mask definition, enabling dynamic parameter composition per mask. This fixes the reported issue where mask params were being ignored.

Please verify that all maskParams scenarios are covered in tests:

  • maskParams: false or null → empty params
  • maskParams: true or undefined → matched params preserved
  • maskParams: (params) => {...} → function transformation applied
  • maskParams: {...} → object merged with matched params

Run the following script to check for existing test coverage of mask params:


🏁 Script executed:

#!/bin/bash
# Search for tests related to route mask params functionality
rg -n -C3 --type=ts --type=tsx 'maskParams|mask.*params|routeMask.*param' -g '*test*' -g '*spec*'

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Search for tests related to route mask params functionality using corrected syntax
rg -n -C3 --type=ts 'maskParams|mask.*params|routeMask' -g '*test*' -g '*spec*'

Length of output: 6422


🏁 Script executed:

#!/bin/bash
# Find test files related to router or mask functionality
fd -e ts -e js '(test|spec)' -path '*router*' -o -path '*mask*'

Length of output: 168


🏁 Script executed:

#!/bin/bash
# Search for maskParams usage anywhere in the codebase to understand scope
rg -n 'maskParams' --type=ts

Length of output: 417


🏁 Script executed:

#!/bin/bash
# Search for createRouteMask definition to understand maskParams support
rg -n -A20 'function createRouteMask|const createRouteMask' --type=ts

Length of output: 2871


🏁 Script executed:

#!/bin/bash
# Search for mask type definition
rg -n 'type.*[Mm]ask|interface.*[Mm]ask' --type=ts -A5 | head -100

Length of output: 2021


🏁 Script executed:

#!/bin/bash
# Look for any tests passing functions as mask params
rg -n 'params.*=>|mask.*function' --type=ts -g '*test*' -g '*spec*' -C2

Length of output: 173798


🏁 Script executed:

#!/bin/bash
# Check RouteMask and ToMaskOptions type definitions for maskParams support
rg -n -A10 'type RouteMask<|type ToMaskOptions<|interface ToMaskOptions' --type=ts packages/router-core/src/

Length of output: 1377


🏁 Script executed:

#!/bin/bash
# Search for functionalUpdate utility used in the maskParams logic
rg -n -B5 -A5 'functionalUpdate' packages/router-core/src/router.ts | head -50

Length of output: 1549


Add tests for maskParams feature before merging.

The implementation correctly handles all four maskParams scenarios (false/null, true/undefined, function transformation, and object merge), following established patterns in the codebase. However, there is no test coverage for this new feature.

Add tests covering:

  • maskParams: false or null → empty params
  • maskParams: true or undefined → matched params preserved
  • maskParams: (params) => {...} → function transformation applied
  • maskParams: {...} → object merged with matched params
🤖 Prompt for AI Agents
In packages/router-core/src/router.ts around lines 1798 to 1812, the new
maskParams handling logic lacks test coverage; add unit tests that exercise all
four branches: (1) maskParams false and null should produce an empty params
object, (2) maskParams true and undefined should preserve the matched params,
(3) maskParams as a function should receive the matched params and the returned
value should be used, and (4) maskParams as an object should be merged with
matched params via the same functionalUpdate semantics. Create tests in the
router-core test suite (e.g., packages/router-core/__tests__ or
tests/router.spec.ts), mock or construct route matches and call the code paths
that produce maskedDest, asserting the resulting maskedDest.params for each
scenario; include edge cases for falsy/undefined returns from the function and
ensure merge semantics match Object.assign(functionalUpdate(...), params).

}
maskedNext = build(maskedDest)
}
Expand Down