feat(PBI-ll): voeg lib/product-switch-path.ts toe met resolveProductSwitchTarget
Pure helper die doel-URL bij product-wissel bepaalt; unit-tests dekken alle pad-gevallen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3ad352c10f
commit
ab8a73d7c3
2 changed files with 69 additions and 0 deletions
14
lib/product-switch-path.ts
Normal file
14
lib/product-switch-path.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export function resolveProductSwitchTarget(
|
||||
pathname: string,
|
||||
newProductId: string,
|
||||
): string | null {
|
||||
const match = pathname.match(/^\/products\/([^/]+)(\/.*)?$/)
|
||||
if (!match) return null
|
||||
|
||||
const rest = match[2] ?? ''
|
||||
|
||||
if (!rest || rest === '/') return `/products/${newProductId}`
|
||||
if (rest.startsWith('/sprint')) return `/products/${newProductId}/sprint`
|
||||
if (rest.startsWith('/solo')) return `/products/${newProductId}/solo`
|
||||
return `/products/${newProductId}`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue