Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from hpcslag/patch-1
Browse files Browse the repository at this point in the history
Fix the problem with regexp with space problem
  • Loading branch information
YamiOdymel authored Jul 14, 2021
2 parents 2767184 + abdbda5 commit 716336a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shopeego.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,11 @@ func (s *ShopeeClient) post(method string, in interface{}) ([]byte, error) {
func (s *ShopeeClient) patchFloat(body []byte) []byte {
replaceConcat := strings.Join(replaces, "|")
for _, v := range replaces {
body = []byte(strings.ReplaceAll(string(body), fmt.Sprintf(`"%s": ""`, v), fmt.Sprintf(`"%s": "0"`, v)))
body = []byte(strings.ReplaceAll(string(body), fmt.Sprintf(`"%s":""`, v), fmt.Sprintf(`"%s":"0"`, v)))
}

var r = regexp.MustCompile(fmt.Sprintf(`"(%s)": ([^"].*?)(,|})`, replaceConcat))
return []byte(r.ReplaceAllString(string(body), `"$1": "$2"$3`))
var r = regexp.MustCompile(fmt.Sprintf(`"(%s)":([^"].*?)(,|})`, replaceConcat))
return []byte(r.ReplaceAllString(string(body), `"$1":"$2"$3`))
}

//=======================================================
Expand Down

0 comments on commit 716336a

Please sign in to comment.