fix(#773): use utf8 encoding when reading file when encoding not specified by options

This commit is contained in:
Ben Heidemann 2021-04-18 13:27:32 +01:00 committed by David Humphrey
parent 51afeeaf54
commit 7b1c3e85ce
1 changed files with 1 additions and 1 deletions

View File

@ -1873,7 +1873,7 @@ function writeFile(context, path, data, options, callback) {
if(typeof data === 'number') {
data = '' + data;
}
if(typeof data === 'string' && options.encoding === 'utf8') {
if(typeof data === 'string' && (options.encoding || 'utf8') === 'utf8') {
data = Buffer.from(data);
}