Closed
Description
Problematic Code:
import Foundation
let dir = URL(fileURLWithPath: "")
print(dir.path) // => /tmp/ee78646dddfd6304
let file = dir.appendingPathComponent("main.swift")
print(file.path) // => /main.swift
As shown in the example, even though dir
holds the path to the current directory, appending a file to it results in an absolute path starting with a slash. This behavior is unexpected because appending to a current directory URL should ideally maintain a relative path, not convert it to an absolute one.
Metadata
Metadata
Assignees
Labels
No labels