lib/plagiarism/strategries/bing.rb in plagiarism2-0.0.3 vs lib/plagiarism/strategries/bing.rb in plagiarism2-0.0.4

- old
+ new

@@ -8,11 +8,12 @@ def fetch(content, params) Typhoeus.get(URL, params: params.merge('$format' => :json, 'Query' => "'#{content}'"), userpwd: ":#{Config.bing_key}") end def exists?(response) - JSON.parse(response)['d']['results'].all? do |r| - uri = URI.parse(r['Url']) + results = JSON.parse(response)['d']['results'] rescue [] + results.all? do |r| + uri = URI.parse URI::encode(r['Url']) uri.host =~ whitelists_regex end end end