I want all single backslashes to be converted into double backslash
"C:\Users\MyName\ringtone.mp3"
--> "C:\\Users\\MyName\\ringtone.mp3"
But for some reason it returns "C:UsersMyNameingtone.mp3"
So far I have tried the escape() function and the encodeURI() function but they don't work either. Partial of the string comes from nodejs OS Module which only returns with a single backslash on windows (homedir() function). Here is what I have so far in the function
function normalize(path: string): string {
return path.normalize().replace(/\\/g, '\\');
}
Thanks in Advance