cjvnjde / google-translate-api-browser

A free and unlimited API for Google Translate
https://www.npmjs.com/package/google-translate-api-browser
MIT License
213 stars 31 forks source link

Handle error of unexpected api response structure #48

Open merickiranoglu opened 2 weeks ago

merickiranoglu commented 2 weeks ago

When a url is provided as text, the api returns a weird data instead of an error. This causes data[1][0][0][5] to be undefined. This PR doesn't fix the error, but provides an information about the problem.

You might want to consider returning the text itself if the text matches with a URL regex pattern. But since that would be a decision, I didn't want to include that to this PR.