diff --git a/lib/functions/url.js b/lib/functions/url.js index cb008fc35..b8269249c 100644 --- a/lib/functions/url.js +++ b/lib/functions/url.js @@ -114,19 +114,19 @@ module.exports = function(options) { } // Read data - var str = fs.readFileSync(found, 'utf8'); + buf = fs.readFileSync(found); // Too large - if(false !== sizeLimit && str.length > sizeLimit) return literal; + if(false !== sizeLimit && buf.length > sizeLimit) return literal; if(enc && 'utf8' == enc.first.val.toLowerCase()) { encoding = encodingTypes.UTF8; - result = str.replace(/\s+/g, ' ') + result = buf.toString().replace(/\s+/g, ' ') .replace(/[{}\|\\\^~\[\]`"<>#%]/g, function(match) { return '%' + match[0].charCodeAt(0).toString(16).toUpperCase(); }).trim(); } else { - result = Buffer.from(str.replace(/\r\n?/g, '\n')).toString(encoding) + hash; + result = buf.toString(encoding) + hash; } // Encode