0299f14a7e
- Remove cache value that was incorrectly nested deeper - Remove extra useEffect (already applied during hydration based on the `useReducer` input) - Add dynamic parameter name into the tree Follow-up to #37551, cleans up some code and prepares for catch-all and optional catch-all routes.
20 lines
593 B
TypeScript
20 lines
593 B
TypeScript
import { Segment } from '../../server/app-render'
|
|
|
|
export const matchSegment = (
|
|
existingSegment: Segment,
|
|
segment: Segment
|
|
): boolean => {
|
|
// Common case: segment is just a string
|
|
if (typeof existingSegment === 'string' && typeof segment === 'string') {
|
|
return existingSegment === segment
|
|
}
|
|
|
|
// Dynamic parameter case: segment is an array with param/value. Both param and value are compared.
|
|
if (Array.isArray(existingSegment) && Array.isArray(segment)) {
|
|
return (
|
|
existingSegment[0] === segment[0] && existingSegment[1] === segment[1]
|
|
)
|
|
}
|
|
|
|
return false
|
|
}
|