(
dest: BuildNextOptions = {},
maskedDest?: BuildNextOptions,
)
| 2015 | } |
| 2016 | |
| 2017 | const buildWithMatches = ( |
| 2018 | dest: BuildNextOptions = {}, |
| 2019 | maskedDest?: BuildNextOptions, |
| 2020 | ) => { |
| 2021 | const next = build(dest) |
| 2022 | |
| 2023 | let maskedNext = maskedDest ? build(maskedDest) : undefined |
| 2024 | |
| 2025 | if (!maskedNext) { |
| 2026 | const params = Object.create(null) |
| 2027 | |
| 2028 | if (this.options.routeMasks) { |
| 2029 | const match = findFlatMatch<RouteMask<TRouteTree>>( |
| 2030 | next.pathname, |
| 2031 | this.processedTree, |
| 2032 | ) |
| 2033 | if (match) { |
| 2034 | Object.assign(params, match.rawParams) // Copy params, because they're cached |
| 2035 | const { |
| 2036 | from: _from, |
| 2037 | params: maskParams, |
| 2038 | ...maskProps |
| 2039 | } = match.route |
| 2040 | |
| 2041 | // If mask has a params function, call it with the matched params as context |
| 2042 | // Otherwise, use the matched params or the provided params value |
| 2043 | const nextParams = |
| 2044 | maskParams === false || maskParams === null |
| 2045 | ? Object.create(null) |
| 2046 | : (maskParams ?? true) === true |
| 2047 | ? params |
| 2048 | : Object.assign(params, functionalUpdate(maskParams, params)) |
| 2049 | |
| 2050 | maskedDest = { |
| 2051 | from: opts.from, |
| 2052 | ...maskProps, |
| 2053 | params: nextParams, |
| 2054 | } |
| 2055 | maskedNext = build(maskedDest) |
| 2056 | } |
| 2057 | } |
| 2058 | } |
| 2059 | |
| 2060 | if (maskedNext) { |
| 2061 | next.maskedLocation = maskedNext |
| 2062 | } |
| 2063 | |
| 2064 | return next |
| 2065 | } |
| 2066 | |
| 2067 | if (opts.mask) { |
| 2068 | return buildWithMatches(opts, { |
nothing calls this directly
no test coverage detected