Fix parsing og sort string
By trimming extra inverted quotes from the sort string
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/slice"
|
||||
@@ -128,19 +129,24 @@ func splitCommaParenthesis(in string) (out []string) {
|
||||
depth--
|
||||
case ',':
|
||||
if depth == 0 {
|
||||
out = append(out, strings.TrimSpace(in[start:i]))
|
||||
out = append(out, trimQuotes(strings.TrimSpace(in[start:i])))
|
||||
start = i + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if start < len(in) {
|
||||
out = append(out, strings.TrimSpace(in[start:]))
|
||||
out = append(out, trimQuotes(strings.TrimSpace(in[start:])))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// trimQuotes removes quotes from the beginning and the end of the string
|
||||
func trimQuotes(in string) string {
|
||||
return regexp.MustCompile(`^"(.*)"$`).ReplaceAllString(in, `$1`)
|
||||
}
|
||||
|
||||
// UnmarshalJSON parses sort expression when passed inside JSON
|
||||
func (set *SortExprSet) UnmarshalJSON(in []byte) error {
|
||||
// This is an edgecase where `sort: ""` is passed in
|
||||
|
||||
Reference in New Issue
Block a user