fix: the robots element follows the Go grammar and keeps a value it cannot parse (WR-24)

parseRobots accepted 2027-02-30 (Date.parse rolls it over) and refused
max-snippet:+5, both unlike classes/robots_value.go. A value it could not
parse showed every group as Inherit and the first click serialised the
empty model, dropping the stored directives. Dates are now checked as
calendar dates, a sign is accepted, and an unparsed value is kept with a
note, the controls off and an explicit Reset.
This commit is contained in:
2026-10-27 15:43:32 +01:00
parent 4ca26e9a89
commit 923d0f9c3a
7 changed files with 121 additions and 10 deletions

View File

@@ -108,6 +108,17 @@ func TestRobotsValueMalformed(t *testing.T) {
}
}
// TestRobotsValueSigned: a signed number is accepted and stored without
// its plus sign, as the element's grammar reads it (WR-24).
func TestRobotsValueSigned(t *testing.T) {
if got, err := NormalizeRobots("max-snippet:+5"); err != nil || got != "max-snippet:5" {
t.Fatalf("NormalizeRobots(max-snippet:+5) = %q, %v", got, err)
}
if _, err := NormalizeRobots("unavailable_after:2028-02-29"); err != nil {
t.Fatalf("leap day: %v", err)
}
}
func TestRobotsValueInherit(t *testing.T) {
parse := func(v string) Robots {
t.Helper()