refactor appeal for new and resume
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// lib/forms/readFormXml.js
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
/**
|
||||
* Reads /data/formsxml/{appealtypes}.xml and normalises it.
|
||||
* Returns { xmlStr } or throws on missing file.
|
||||
*/
|
||||
export function readFormXml(appealtypes) {
|
||||
if (!appealtypes) throw new Error("readFormXml: appealtypes is required");
|
||||
|
||||
const configDirectory = path.resolve(process.cwd(), "data/formsxml");
|
||||
const filePath = path.join(configDirectory, `${appealtypes}.xml`);
|
||||
|
||||
let xmlStr = fs.readFileSync(filePath, "utf8");
|
||||
|
||||
// Keep existing normalisation behaviour
|
||||
xmlStr = xmlStr.replace(/\t/g, "");
|
||||
xmlStr = xmlStr.replace(/\n/g, "");
|
||||
xmlStr = xmlStr.replace(/> <"/g, "><");
|
||||
xmlStr = xmlStr.toString();
|
||||
|
||||
return { xmlStr, filePath };
|
||||
}
|
||||
Reference in New Issue
Block a user