ruby-duck-duck-go icon indicating copy to clipboard operation
ruby-duck-duck-go copied to clipboard

JSON::ParserError when handling queries that redirect to another search engine.

Open woodruffw opened this issue 10 years ago • 0 comments

Hello,

DuckDuckGo queries like !g apple redirect to the search engine specified after the bang (g is Google, w is Wikipedia, etc). This causes the API to return HTML not JSON, causing a parser error on duck_duck_go.rb:49.

The ugly fix is just to guard the JSON.parse call. A better one might be to check the origin of the data being received (not sure if that's possible yet, haven't done enough research).

Best, William

woodruffw avatar Sep 23 '15 18:09 woodruffw