fix(xml saving): if the stirng has
\r we now flatten it so its proper and not create a new folder
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user