Skip to content

Deleting last path component on Linux can result in URL with empty path #980

Closed
@ahoppen

Description

@ahoppen
var url = URL(fileURLWithPath: "/whatever/test.swift")
print("'\(url.path)'") // prints '/whatever/test.swift'
url.deleteLastPathComponent()
print("'\(url.path)'") // prints '/whatever'
url.deleteLastPathComponent()
print("'\(url.path)'") // prints ''

url = URL(fileURLWithPath: "/test.swift")
print("'\(url.path)'") // prints '/test.swift'
url.deleteLastPathComponent()
print("'\(url.path)'") // prints '/'

Where it prints '' at the end of the first section, I think it should print /.

This is in a Swift 6.0 Linux docker image.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions