Scrum4Me/lib/product-switch-path.ts
Scrum4Me Agent ab8a73d7c3 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>
2026-05-14 21:36:57 +02:00

14 lines
479 B
TypeScript

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