Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
body.copy(body2, 0, 2);
response.body = body2.toString('utf16le');
} else if (body[0] === 0xFF && body[1] === 0xFE) {
// UTF-16 little-endian
const body2 = Buffer.allocUnsafe(body.length - 2);
body.copy(body2, 0, 2);
response.body = body2.toString('utf16le');
} else {
// UTF-8
response.body = body.toString('binary');
}
}
if (options.fixCharset) {
response.body = response.body.replace('charset=utf-16le', 'utf-8');
if (response.body.match(/charset=windows-1252/)) {
response.body = windows1252.decode(response.body);
}
}
const page = newPage({
uri,
response,
body: response.body,
code: response.statusCode,
agent
});
addResponseCookies({
response,
uri: new URL(uri),
page
});
history.push(page);