Skip to content

Commit 9005409

Browse files
committed
admin: fixed edit-sites escape string and fs sync issue
1 parent a05b86f commit 9005409

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/routes/edit-sites.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ const router = express.Router();
77
// TODO: Check if the user is actually online (calling EPCs is_online/status)
88
router.post('/secure/edit_sites', connectEnsureLogin.ensureLoggedIn(), async (req: Request, res: Response) => {
99
try {
10-
const sites = req.body.sites.replace(/(^"|"$)/g, '');
11-
fs.writeFile(__dirname + '/../../models/sites.json', JSON.stringify(sites).replace(/\\/g, ""), function(err) {
10+
const sites = JSON.parse(req.body.sites);
11+
fs.writeFile(__dirname + '/../../models/sites.json', JSON.stringify(sites), function(err) {
12+
// const sites = req.body.sites.replace(/(^"|"$)/g, '');
13+
// fs.writeFile(__dirname + '/../../models/sites.json', JSON.stringify(sites).replace(/\\/g, ""), function(err) {
1214
if (err) {
1315
console.error(err);
1416
res.status(500).send("database error");

src/routes/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function updateSite() {
6767
}
6868
}
6969
router.get('/api/sites', (_, res: Response) => {
70-
updateSite();
70+
sites = updateSite();
7171
res.send(sites);
7272
});
7373

0 commit comments

Comments
 (0)