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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user