diff --git a/lstV2/server/services/notifications/utils/saveXml.ts b/lstV2/server/services/notifications/utils/saveXml.ts index 743a194..b630d9c 100644 --- a/lstV2/server/services/notifications/utils/saveXml.ts +++ b/lstV2/server/services/notifications/utils/saveXml.ts @@ -2,12 +2,18 @@ import fs from "fs"; import path from "path"; import { createLog } from "../../logger/logger.js"; +const cleanStringForFilename = (str: string) => { + // Remove CRLF and LF newlines + return str.replace(/(\r\n|\n|\r)/gm, " "); // or "" if you want no space at all +}; + /** * Save XML string to /xml/ with timestamp in name * @param xmlContent The XML string * @param prefix File prefix (ex: request or response) */ -export const saveXml = (xmlContent: string, prefix: string = "request") => { +export const saveXml = (xmlContent: string, nameString: string = "request") => { + const prefix = cleanStringForFilename(nameString); try { const now = new Date();