-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1226 from Luap99/format-json
pkg/report: fix IsJSON()
- Loading branch information
Showing
2 changed files
with
8 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
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 | ||
// | ||
// if report.IsJSON(cmd.Flag("format").Value.String()) { | ||
// ... process JSON and output | ||
// } | ||
func IsJSON(s string) bool { | ||
return jsonRegex.MatchString(s) | ||
return strings.TrimSpace(s) == "json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters