Skip to content

Commit

Permalink
cmd/bosun: allow comments after last line in web expr ui (keep this c…
Browse files Browse the repository at this point in the history
…ommit)
  • Loading branch information
kylebrandt committed Jul 31, 2018
1 parent 861cc02 commit d07cf32
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/bosun/web/expr.go
Expand Up @@ -42,8 +42,15 @@ func Expr(t miniprofiler.Timer, w http.ResponseWriter, r *http.Request) (v inter
if err != nil {
return nil, err
}

lines := strings.Split(strings.TrimSpace(string(text)), "\n")
rawLines := strings.Split(strings.TrimSpace(string(text)), "\n")
var lines []string
for _, line := range rawLines {
// remove comments and empty lines before processing so comments can be after the final line
if line == "" || strings.HasPrefix(line, "#") {
continue
}
lines = append(lines, line)
}
var expression string
vars := map[string]string{}
varRegex := regexp.MustCompile(`(\$\w+)\s*=(.*)`)
Expand Down

0 comments on commit d07cf32

Please sign in to comment.