mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
fix(rules): prevent appending empty command parts in forEachPipePart and remove redundant calculation in parseDoWithBlocks function
This commit is contained in:
@@ -417,10 +417,6 @@ func parseDoWithBlocks(src string) (handlers []CommandHandler, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not a nested block; parse the rest of this line as a command.
|
// Not a nested block; parse the rest of this line as a command.
|
||||||
lineEnd = pos
|
|
||||||
for lineEnd < length && src[lineEnd] != '\n' {
|
|
||||||
lineEnd++
|
|
||||||
}
|
|
||||||
if lerr := appendLineCommand(src[pos:lineEnd]); lerr != nil {
|
if lerr := appendLineCommand(src[pos:lineEnd]); lerr != nil {
|
||||||
return nil, lerr
|
return nil, lerr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -651,7 +651,9 @@ func forEachPipePart(s string, fn func(part string)) {
|
|||||||
}
|
}
|
||||||
case '|':
|
case '|':
|
||||||
if quote == 0 && brackets == 0 {
|
if quote == 0 && brackets == 0 {
|
||||||
fn(strings.TrimSpace(s[start:i]))
|
if part := strings.TrimSpace(s[start:i]); part != "" {
|
||||||
|
fn(part)
|
||||||
|
}
|
||||||
start = i + 1
|
start = i + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user