diff --git a/libraries/stdlib/src/kotlin/io/files/FilePathComponents.kt b/libraries/stdlib/src/kotlin/io/files/FilePathComponents.kt index 1c0ba388f52..82701ce7309 100644 --- a/libraries/stdlib/src/kotlin/io/files/FilePathComponents.kt +++ b/libraries/stdlib/src/kotlin/io/files/FilePathComponents.kt @@ -138,11 +138,7 @@ internal fun File.toComponents(): FilePathComponents { val rootLength = path.getRootLength() val rootName = path.substring(0, rootLength) val subPath = path.substring(rootLength) - // if: a special case when we have only root component - // Split not only by / or \, but also by //, ///, \\, \\\, etc. - val list = if (subPath.isEmpty()) listOf() else - // Looks awful but we split just by /+ or \+ depending on OS - subPath.split(Regex.fromLiteral(File.separatorChar.toString())).map { it -> File(it) } + val list = if (subPath.isEmpty()) listOf() else subPath.split(File.separatorChar).map { File(it) } return FilePathComponents(File(rootName), list) }