harden(forms): use const for derived field-key base (Phase 3 audit)

This commit is contained in:
Moheeb Zara
2026-05-16 15:15:17 -07:00
parent 03bb3a7466
commit 01b924b2f5
+1 -1
View File
@@ -62,7 +62,7 @@ function slugify(s: string, sep: '-' | '_') {
function deriveKeys(fields: FormField[]): FormField[] {
const seen = new Set<string>()
return fields.map((f, i) => {
let base = slugify(f.label || '', '_') || `field_${i + 1}`
const base = slugify(f.label || '', '_') || `field_${i + 1}`
let key = base
let n = 2
while (seen.has(key)) key = `${base}_${n++}`