Browse Source

修改HttpBuildQuery

master
guzeng 3 years ago
parent
commit
2f5cf759be
2 changed files with 4 additions and 2 deletions
  1. +3
    -1
      map.go
  2. +1
    -1
      map_test.go

+ 3
- 1
map.go View File

@ -112,7 +112,9 @@ func HttpBuildQuery(data map[string]string) string {
var query string var query string
for _, value := range keySlice { for _, value := range keySlice {
query += StringJoin(value, "=", data[value], "&")
if data[value] != "" {
query += StringJoin(value, "=", data[value], "&")
}
} }
return strings.Trim(query, "&") return strings.Trim(query, "&")


+ 1
- 1
map_test.go View File

@ -6,7 +6,7 @@ import (
func Test_HttpBuildQuery(t *testing.T) { func Test_HttpBuildQuery(t *testing.T) {
list := map[string]string{"a": "b", "c": "d", "b": "f"}
list := map[string]string{"a": "b", "c": "cdd", "b": ""}
ret := HttpBuildQuery(list) ret := HttpBuildQuery(list)


Loading…
Cancel
Save