I have a logger class in my JavaScript that has the following line at some point:
// some function class that has `msg: string` variable
msg = msg.replace(/\\/g, '');
My logger has some syntax such as --some string-- that gets a markup. But if someone wants to actually print -- then they would escape it with "\\-\\-some string\\-\\-".
Now this all works well. However, on a Windows machine, file paths use \ and when I try to print for example logger.info(process.cwd()), that line msg.replace(/\\/g, '') replaces all the slashes in the path and I end up getting something like C:userskoushadocumentsnode_modules
How can I handle both windows file path and the ability to escape characters?