Skip to content

Commit

Permalink
fix: correct RequestParamValue.String
Browse files Browse the repository at this point in the history
  • Loading branch information
aofei committed Nov 18, 2020
1 parent 1917812 commit aa43f1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package air
import (
"context"
"errors"
"fmt"
"io"
"mime/multipart"
"net"
Expand Down Expand Up @@ -744,12 +743,8 @@ func (rpv *RequestParamValue) Float64() (float64, error) {
// if the rpv is not text-based.
func (rpv *RequestParamValue) String() string {
if rpv.s == nil {
if s, ok := rpv.i.(string); ok {
rpv.s = &s
} else {
s := fmt.Sprint(rpv.i)
rpv.s = &s
}
s, _ := rpv.i.(string)
rpv.s = &s
}

return *rpv.s
Expand Down
4 changes: 2 additions & 2 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ func TestRequestParamValueString(t *testing.T) {
assert.Nil(t, rpv.s)

s = rpv.String()
assert.Equal(t, "foobar", s)
assert.Empty(t, s)
assert.NotNil(t, rpv.s)
}

Expand All @@ -809,7 +809,7 @@ func TestRequestParamValueBytes(t *testing.T) {
assert.Nil(t, rpv.s)

b = rpv.Bytes()
assert.Equal(t, []byte("foobar"), b)
assert.Nil(t, b)
assert.NotNil(t, rpv.s)
}

Expand Down

0 comments on commit aa43f1c

Please sign in to comment.