diff --git a/Sources/System/FilePath/FilePathParsing.swift b/Sources/System/FilePath/FilePathParsing.swift index f372dd67..efff3492 100644 --- a/Sources/System/FilePath/FilePathParsing.swift +++ b/Sources/System/FilePath/FilePathParsing.swift @@ -168,7 +168,7 @@ extension FilePath { readIdx = nextStart continue } - assert(self.root == nil && self.components.first!.kind == .parentDirectory) + assert(!hasRoot && _isParentDirectory(priorComponent)) } } diff --git a/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift b/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift index 0fdfbc27..9df2019e 100644 --- a/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift +++ b/Tests/SystemTests/FilePathTests/FilePathSyntaxTest.swift @@ -436,6 +436,13 @@ final class FilePathSyntaxTest: XCTestCase { lexicallyNormalized: ".." ), + .unix( + "foo/../../../bar", + dirname: "foo/../../..", basename: "bar", + components: ["foo", "..", "..", "..", "bar"], + lexicallyNormalized: "../../bar" + ), + .unix( "a/.././.././../b", dirname: "a/.././.././..", basename: "b",