Skip to content

Commit 16f008a

Browse files
authored
Merge pull request #95 from thespooler/master
Ignore BOM when reading config
2 parents ecce122 + 205b607 commit 16f008a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

defaultConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"web": {
33
"servers": {
44
"http2": { "enabled": false },

server/config/Config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class Config {
1010
this.cfgPath = path.posix.join(process.cwd(), "/config.json");
1111
// RKS 05-18-20: This originally had multiple points of failure where it was not in the try/catch.
1212
try {
13-
this._cfg = fs.existsSync(this.cfgPath) ? JSON.parse(fs.readFileSync(this.cfgPath, "utf8")) : {};
14-
const def = JSON.parse(fs.readFileSync(path.join(process.cwd(), "/defaultConfig.json"), "utf8").trim());
15-
const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), "/package.json"), "utf8").trim());
13+
this._cfg = fs.existsSync(this.cfgPath) ? JSON.parse(fs.readFileSync(this.cfgPath, "utf8").replace(/^\uFEFF/, '')) : {};
14+
const def = JSON.parse(fs.readFileSync(path.join(process.cwd(), "/defaultConfig.json"), "utf8").replace(/^\uFEFF/, '').trim());
15+
const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), "/package.json"), "utf8").replace(/^\uFEFF/, '').trim());
1616
this._cfg = extend(true, {}, def, this._cfg, { appVersion: { installed: packageJson.version } });
1717
this._isInitialized = true;
1818
this.getEnvVariables();

0 commit comments

Comments
 (0)