ruby-duck-duck-go
ruby-duck-duck-go copied to clipboard
JSON::ParserError when handling queries that redirect to another search engine.
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