Skip to content

Commit

Permalink
parse google response appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
xwjdsh committed Aug 9, 2021
1 parent d3954e4 commit ee8db95
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion google.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (g *googleTranslator) translate(ctx context.Context, req Request) (resp *Re
}

func (g *googleTranslator) getResult(dataStr string) (string, error) {
result := regexp.MustCompile(`(?U),\[\[\\"(.*)\\",\[`).FindStringSubmatch(dataStr)
result := regexp.MustCompile(`null,\[\[\\"(?P<result>.+)\\",null,null,null`).FindStringSubmatch(dataStr)
if len(result) != 2 {
return "", fmt.Errorf("cannot get result")
}
Expand Down

0 comments on commit ee8db95

Please sign in to comment.