diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2018-08-17 16:04:46 +0800 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2018-08-21 22:36:22 +0800 |
commit | 1e7885eb56cdf4c6f550e143b0dbd3acc82a4137 (patch) | |
tree | f1cdb5d92bfbad07e5fce2add5598699732ce253 /args.go | |
parent | Merge pull request #303 from chebyrash/master (diff) | |
download | fasthttp-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.go | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 |