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:
Scrum4Me Agent 2026-05-14 21:36:57 +02:00
parent 3ad352c10f
commit ab8a73d7c3
2 changed files with 69 additions and 0 deletions

View 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}`
}