aboutsummaryrefslogtreecommitdiff
path: root/args.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2018-08-17 16:04:46 +0800
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2018-08-21 22:36:22 +0800
commit1e7885eb56cdf4c6f550e143b0dbd3acc82a4137 (patch)
treef1cdb5d92bfbad07e5fce2add5598699732ce253 /args.go
parentMerge pull request #303 from chebyrash/master (diff)
downloadfasthttp-1e7885eb56cdf4c6f550e143b0dbd3acc82a4137.tar.gz
fasthttp-1e7885eb56cdf4c6f550e143b0dbd3acc82a4137.tar.bz2
fasthttp-1e7885eb56cdf4c6f550e143b0dbd3acc82a4137.zip
handle 't' and 'true' as bool in QueryArgs
See: https://github.com/erikdubbelboer/fasthttp/pull/46
Diffstat (limited to 'args.go')
-rw-r--r--args.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/args.go b/args.go
index e278561..2781593 100644
--- a/args.go
+++ b/args.go
@@ -287,11 +287,14 @@ func (a *Args) GetUfloatOrZero(key string) float64 {
// GetBool returns boolean value for the given key.
//
-// true is returned for '1', 'y' and 'yes' values,
+// true is returned for "1", "t", "T", "true", "TRUE", "True", "y", "yes", "Y", "YES", "Yes",
// otherwise false is returned.
func (a *Args) GetBool(key string) bool {
- switch string(a.Peek(key)) {
- case "1", "y", "yes":
+ switch b2s(a.Peek(key)) {
+ // Support the same true cases as strconv.ParseBool
+ // See: https://github.com/golang/go/blob/4e1b11e2c9bdb0ddea1141eed487be1a626ff5be/src/strconv/atob.go#L12
+ // and Y and Yes versions.
+ case "1", "t", "T", "true", "TRUE", "True", "y", "yes", "Y", "YES", "Yes":
return true
default:
return false