Skip to content

Commit

Permalink
remove IE comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjatse committed Sep 23, 2019
1 parent 3fc7ade commit 4c65a3f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/req.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var debug = require('debug')('reqfast.request')
var util = require('./util')
var regUTF8 = /^utf-*8$/i
var regMeta = /<meta(?!\s*(?:name|value)\s*=)[^>]*?charset\s*=[\s"']*([^\s"'/>]*)/i
var regIEComments = /<!--\[if [lg]te? IE \d+\]>.+<!\[endif\]-->/gi

module.exports = req

Expand Down Expand Up @@ -139,7 +140,7 @@ function _getContentType (resp) {
}

if (!charset && mime === 'text/html') {
var html = resp.body.toString('ascii')
var html = resp.body.toString('ascii').replace(regIEComments, '')
var meta
if ((meta = html.match(regMeta)) && meta.length > 1) {
charset = meta[1]
Expand Down

0 comments on commit 4c65a3f

Please sign in to comment.