import type { PricingPackage } from '../content/types.ts'; // The package id from ?pakket=, if it names one of the given packages. // Letter case and surrounding spaces do not matter; anything else (unknown // id, number, array, missing) is ignored. Only our own ids can come out, so // the value from the URL is never reflected on the page (BR-PARAM-01). export function packageFromSearch( value: unknown, packages: readonly PricingPackage[], ): string | undefined { if (typeof value !== 'string') return undefined; const wanted = value.trim().toLowerCase(); return packages.find((pkg) => pkg.id === wanted)?.id; }