2026-02-16 23:40:40 +00:00
|
|
|
package html
|
|
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
2026-04-03 17:23:37 +00:00
|
|
|
// path.go: ParseBlockID extracts the slot sequence from a data-block ID.
|
2026-04-03 17:14:10 +00:00
|
|
|
// Example: ParseBlockID("L-0-C-0") returns []byte{'L', 'C'}.
|
2026-02-16 23:40:40 +00:00
|
|
|
func ParseBlockID(id string) []byte {
|
|
|
|
|
if id == "" {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-03 17:14:10 +00:00
|
|
|
// Split on "-" and require the exact structural pattern:
|
|
|
|
|
// slot, 0, slot, 0, ...
|
2026-02-16 23:40:40 +00:00
|
|
|
var slots []byte
|
2026-02-23 05:11:04 +00:00
|
|
|
i := 0
|
|
|
|
|
for part := range strings.SplitSeq(id, "-") {
|
2026-04-03 17:14:10 +00:00
|
|
|
if i%2 == 0 {
|
|
|
|
|
if len(part) != 1 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2026-04-03 17:25:49 +00:00
|
|
|
if _, ok := slotRegistry[part[0]]; !ok {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2026-02-23 05:11:04 +00:00
|
|
|
slots = append(slots, part[0])
|
2026-04-03 17:14:10 +00:00
|
|
|
} else if part != "0" {
|
|
|
|
|
return nil
|
2026-02-16 23:40:40 +00:00
|
|
|
}
|
2026-02-23 05:11:04 +00:00
|
|
|
i++
|
2026-02-16 23:40:40 +00:00
|
|
|
}
|
2026-04-03 17:14:10 +00:00
|
|
|
if i == 0 || i%2 != 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2026-02-16 23:40:40 +00:00
|
|
|
return slots
|
|
|
|
|
}
|