diff --git a/pkg/report/validate.go b/pkg/report/validate.go index 987b13a6a..f4e059b09 100644 --- a/pkg/report/validate.go +++ b/pkg/report/validate.go @@ -1,8 +1,6 @@ package report -import "regexp" - -var jsonRegex = regexp.MustCompile(`^\s*(json|{{\s*json\s*(\.)?\s*}})\s*$`) +import "strings" // JSONFormat test CLI --format string to be a JSON request // @@ -10,5 +8,5 @@ var jsonRegex = regexp.MustCompile(`^\s*(json|{{\s*json\s*(\.)?\s*}})\s*$`) // ... process JSON and output // } func IsJSON(s string) bool { - return jsonRegex.MatchString(s) + return strings.TrimSpace(s) == "json" } diff --git a/pkg/report/validate_test.go b/pkg/report/validate_test.go index 590735e84..3e21e4550 100644 --- a/pkg/report/validate_test.go +++ b/pkg/report/validate_test.go @@ -17,17 +17,16 @@ func TestIsJSON(t *testing.T) { {" json", true}, {" json ", true}, {" json ", true}, - {"{{json}}", true}, - {"{{json }}", true}, - {"{{json .}}", true}, - {"{{ json .}}", true}, - {"{{ json . }}", true}, - {" {{ json . }} ", true}, + {"{{json}}", false}, + {"{{json }}", false}, + {"{{json .}}", false}, + {"{{ json .}}", false}, + {"{{ json . }}", false}, + {" {{ json . }} ", false}, {"{{ json .", false}, {"json . }}", false}, {"{{.ID }} json .", false}, {"json .", false}, - {"{{json.}}", true}, } for _, tc := range tests {