snowtrack / snowfs

SnowFS - a fast, scalable version control file storage for graphic files :art:
https://www.snowtrack.io
GNU General Public License v3.0
1.3k stars 42 forks source link

Replacement of a substring with itself #261

Open sebastianrath opened 2 years ago

sebastianrath commented 2 years ago

See: https://github.com/snowtrack/snowfs/pull/255/checks?check_run_id=5491245213

https://github.com/snowtrack/snowfs/security/code-scanning/1?query=ref%3Arefs%2Fpull%2F255%2Fmerge+ref%3Arefs%2Fpull%2F255%2Fhead

export function jsonCompliant(s : string) : string {
  return s
    .replace(/\\n/g, '\\n')
    .replace(/\\'/g, "\\'")
    .replace(/\\"/g, '\\"')
    .replace(/\\&/g, '\\&')
    .replace(/\\r/g, '\\r')
    .replace(/\\t/g, '\\t')
    .replace(/\\b/g, '\\b')
    .replace(/\\f/g, '\\f');
}