server: remove BOM when loading json files
This commit is contained in:
parent
0412ba2c28
commit
233c9c8920
1 changed files with 5 additions and 1 deletions
|
|
@ -150,8 +150,11 @@ module.exports = {
|
|||
send = false
|
||||
}
|
||||
}
|
||||
|
||||
var stateContent = fs.readFileSync(settings.read('state'), 'utf8')
|
||||
if (stateContent[0] === '\ufeff') stateContent = stateContent.slice(1) // remove BOM
|
||||
var state = {
|
||||
state: JSON.parse(fs.readFileSync(settings.read('state'), 'utf8')),
|
||||
state: JSON.parse(stateContent),
|
||||
send: send
|
||||
}
|
||||
ipc.send('stateLoad', state, clientId)
|
||||
|
|
@ -182,6 +185,7 @@ module.exports = {
|
|||
error = err
|
||||
} else {
|
||||
try {
|
||||
if (result[0] === '\ufeff') result = result.slice(1) // remove BOM
|
||||
result = data.raw ? result : JSON.parse(result)
|
||||
callback(result)
|
||||
} catch(err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue