normalizeRemotePath function
path normalized under the path rules of a node: POSIX, or — when
windows (by default: when path is a Windows path) — Windows, in its
native form: \ separators (/ accepted on input, so //server/share
from git is the share it names), a drive root keeping its \, and ..
stopping at the drive or share root.
Implementation
String normalizeRemotePath(String path, {bool? windows}) {
if (!(windows ?? isWindowsRemotePath(path))) return p.posix.normalize(path);
final s = path.replaceAll('/', r'\');
return p.windows.normalize(RegExp(r'^[A-Za-z]:$').hasMatch(s) ? '$s\\' : s);
}