String (@NotNull String path) { path = FileUtilRt.toSystemIndependentName(path); path = trimTrailingSeparators(path); for (int i = 0; i < path.length(); ) { int slash = path.indexOf('/', i); if (slash == -1 || slash == path.length()-1) { break; } char next = path.charAt(slash + 1); if (next == '/' && i != 0 || next == '/' && !SystemInfo.isWindows ||// additional condition for Windows UNC next == '/' && slash == 2 && OSAgnosticPathUtil.startsWithWindowsDrive(path) || // Z://foo -> Z:/foo next == '.' && (slash == path.length()-2 || path.charAt(slash+2) == '/')) { return cleanupTail(path, slash); } i = slash + 1; } return path; }