Skip to content

Commit 50d7537

Browse files
authored
FoundationEssentials: handle canonical and non-canonical paths (#668)
In the case that the path is canonicalised, the `/` would be replaced with `\`. The leading `\` would interfere with our ability to recognise the absolute path representation and thus get the wrong response.
1 parent 1d8050c commit 50d7537

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/FoundationEssentials/String/String+Internals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension String {
2929
}
3030

3131
var iter = self.utf8.makeIterator()
32-
let bLeadingSlash = if iter.next() == ._slash, iter.next()?.isLetter ?? false, iter.next() == ._colon { true } else { false }
32+
let bLeadingSlash = if [._slash, ._backslash].contains(iter.next()), iter.next()?.isLetter ?? false, iter.next() == ._colon { true } else { false }
3333

3434
// Strip the leading `/` on a RFC8089 path (`/[drive-letter]:/...` ). A
3535
// leading slash indicates a rooted path on the drive for the current

0 commit comments

Comments
 (0)