Skip to content

URL.path returns forward slashes instead of backslashes on Windows #973

Open
@ahoppen

Description

@ahoppen
print(URL(fileURLWithPath: #"C:\Users\alex"#).path)
print(URL(fileURLWithPath: #"C:/Users/alex"#).path)

Both print statements above print C:/Users/alex. I think they should print C:\Users\alex.

Maybe worth noting: Using withUnsafeFileSystemRepresentation returns backslashes. Should that be exposed through URL.path?

URL(fileURLWithPath: #"C:/Users/alex"#).withUnsafeFileSystemRepresentation {
    print(String(cString: $0!))
}
// prints C:\Users\alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    windowsIssue regarding compiling/running on Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions