Normalize file path slashes
JavaScript version
const normalizePath = (path) => path.replace(/[\\/]+/g, '/');
TypeScript version
const normalizePath = (path: string): string => path.replace(/[\\/]+/g, '/');
Examples
normalizePath('\\foo\\bar\\baz\\'); // /foo/bar/baz/
normalizePath('.//foo//bar///////baz/'); // ./foo/bar/baz/