mirror of
https://github.com/yusing/godoxy.git
synced 2026-02-24 03:14:50 +01: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.
|
||||
lineEnd = pos
|
||||
for lineEnd < length && src[lineEnd] != '\n' {
|
||||
lineEnd++
|
||||
}
|
||||
if lerr := appendLineCommand(src[pos:lineEnd]); lerr != nil {
|
||||
return nil, lerr
|
||||
}
|
||||
|
||||
@@ -651,7 +651,9 @@ func forEachPipePart(s string, fn func(part string)) {
|
||||
}
|
||||
case '|':
|
||||
if quote == 0 && brackets == 0 {
|
||||
fn(strings.TrimSpace(s[start:i]))
|
||||
if part := strings.TrimSpace(s[start:i]); part != "" {
|
||||
fn(part)
|
||||
}
|
||||
start = i + 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user