Skip to content

Commit

Permalink
Fix that sh1t that nytimes.com is doing - no content-type?!?da faq NYT!
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyLemon authored and dz0ny committed Feb 23, 2017
1 parent ff25fd0 commit 9c78940
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/fat.coffee
Expand Up @@ -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
Expand Down

0 comments on commit 9c78940

Please sign in to comment.