Permalink
Browse files

Fix that sh1t that nytimes.com is doing - no content-type?!?da faq NYT!

  • Loading branch information...
1 parent ff25fd0 commit 9c789408206b792b93c05439347346d4ffc7c79a @CrazyLemon CrazyLemon committed with dz0ny Feb 23, 2017
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/fat.coffee
View
@@ -263,7 +263,11 @@ Bot::keyhash = (data)->
Bot::fetchHTML = (url, cb)->
@fetch url, (e, r, body)->
- type = r.headers["content-type"]
+ if r is undefined
+ # something is seriously wrong - we should ignore it and carry on
+ type = "text/html; charset=utf-8"
+ else
+ type = r.headers["content-type"]
if !e and r.statusCode is 200 and type.indexOf('html') != -1
cb( cheerio.load(body) )
else

0 comments on commit 9c78940

Please sign in to comment.