Merged PR 2315: Auth stabilistatiion and hardening
Related work items: #23020
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const xmlCache = new Map();
|
||||
|
||||
/**
|
||||
* Reads /data/formsxml/{appealtypes}.xml and normalises it.
|
||||
* Returns { xmlStr } or throws on missing file.
|
||||
@@ -12,6 +14,12 @@ export function readFormXml(appealtypes) {
|
||||
const configDirectory = path.resolve(process.cwd(), "data/formsxml");
|
||||
const filePath = path.join(configDirectory, `${appealtypes}.xml`);
|
||||
|
||||
const cacheKey = filePath;
|
||||
const cached = xmlCache.get(cacheKey);
|
||||
if (cached) {
|
||||
return { xmlStr: cached, filePath, fromCache: true };
|
||||
}
|
||||
|
||||
let xmlStr = fs.readFileSync(filePath, "utf8");
|
||||
|
||||
// Keep existing normalisation behaviour
|
||||
@@ -20,5 +28,7 @@ export function readFormXml(appealtypes) {
|
||||
xmlStr = xmlStr.replace(/> <"/g, "><");
|
||||
xmlStr = xmlStr.toString();
|
||||
|
||||
xmlCache.set(cacheKey, xmlStr);
|
||||
|
||||
return { xmlStr, filePath };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user