mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 22:43:06 -04:00
[bug][cache][banner] fix utf-8 conversion breaking banners
This commit is contained in:
parent
00b1447600
commit
502017daef
11
src/cache.js
11
src/cache.js
@ -17,8 +17,15 @@ export class CacheObject {
|
||||
}
|
||||
|
||||
if (fs.existsSync(this.path) && fs.statSync(this.path).mtimeMs >= (new Date() - this.maxAgeMinutes*60*1000)) {
|
||||
const content = fs.readFileSync(this.path).toString('utf-8');
|
||||
return this.path.endsWith('.js') ? JSON.parse(content) : content;
|
||||
let content = fs.readFileSync(this.path);
|
||||
if (this.path.endsWith('.js') || this.path.endsWith('.txt')) {
|
||||
content = content.toString('utf-8')
|
||||
}
|
||||
if (this.path.endsWith('.js')) {
|
||||
content = JSON.parse(content);
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
const result = await generator();
|
||||
|
Loading…
x
Reference in New Issue
Block a user