Link detected cookies to existing patterns on conflict

When a cookie pattern already exists for a banner, the insert
conflict caused a continue that silently dropped the detected
cookie instead of linking it to the existing pattern. Load the
existing pattern to obtain its ID and proceed with cookie
insertion.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-30 11:45:02 +04:00
parent 426066e078
commit 33abbfbb8f
3 changed files with 16 additions and 9 deletions

View File

@@ -43,8 +43,10 @@ export function humanizeSeconds(seconds: number | null): string {
}
export function toMaxAgeSeconds(value: string, unit: string): number | null {
const num = parseFloat(value);
if (isNaN(num) || num <= 0) return null;
const trimmed = value.trim();
if (trimmed === "" || !/^\d+(\.\d+)?$/.test(trimmed)) return null;
const num = Number(trimmed);
if (!Number.isFinite(num) || num <= 0) return null;
const u = DURATION_UNITS.find(u => u.value === unit);
if (!u) return null;
const rounded = Math.round(num * u.seconds);