fix optional identity parsing (no idempotent)
This commit is contained in:
@@ -25,6 +25,9 @@ func Parse(str string) (Selector, error) {
|
|||||||
if str == "." {
|
if str == "." {
|
||||||
return identity, nil
|
return identity, nil
|
||||||
}
|
}
|
||||||
|
if str == ".?" {
|
||||||
|
return Selector{segment{str: ".?", identity: true, optional: true}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
col := 0
|
col := 0
|
||||||
var sel Selector
|
var sel Selector
|
||||||
@@ -32,7 +35,7 @@ func Parse(str string) (Selector, error) {
|
|||||||
seg := tok
|
seg := tok
|
||||||
opt := strings.HasSuffix(tok, "?")
|
opt := strings.HasSuffix(tok, "?")
|
||||||
if opt {
|
if opt {
|
||||||
seg = tok[0 : len(tok)-1]
|
seg = strings.TrimRight(tok, "?")
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case seg == ".":
|
case seg == ".":
|
||||||
|
|||||||
Reference in New Issue
Block a user