Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending to an empty file path results in an absolute path #921

Open
omochi opened this issue Sep 18, 2024 · 0 comments
Open

Appending to an empty file path results in an absolute path #921

omochi opened this issue Sep 18, 2024 · 0 comments

Comments

@omochi
Copy link

omochi commented Sep 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant