Compare and cache a read by its one spelling, so two spellings of one reference are one level; reject a slash after a sigil naming the spelling
Tests / vet + fmt + tests (pull_request) Successful in 55s

This commit is contained in:
2026-09-02 18:45:31 +02:00
parent 512696722d
commit fdbbf94d2c
5 changed files with 79 additions and 69 deletions
+6 -1
View File
@@ -29,6 +29,9 @@ func refShape(name string) (sigil, rest string, err error) {
if rest == "" {
return "", "", fmt.Errorf("reference has no path")
}
if strings.HasPrefix(rest, "/") {
return "", "", fmt.Errorf("the path after %s starts at a name, not a /; write {%s%s}", sigil, sigil, rest[1:])
}
if strings.HasPrefix(rest, ".") {
return "", "", fmt.Errorf("a reference starts with / (the root), . (this folder) or .. (the folder above)")
}
@@ -137,7 +140,9 @@ func eachTemplate(root map[string]node, fn func(folder []string, path string, t
}
// resolveRef walks a reference path through the folders to the category it names,
// returning that head, the node, and the tail left to read into it.
// returning that head, the node, and the tail left to read into it. A descent of
// its own rather than a walkPath: it walks groups only and returns where they end,
// not a leaf.
func resolveRef(root map[string]node, segments []string) (head []string, target node, tail []string, err error) {
var n node = &group{children: root}
i := 0