-
Notifications
You must be signed in to change notification settings - Fork 170
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
Behavior of joining paths starting with "/" is unnatural #12
Comments
I disagree that this is unnatural, it's actually consistent with many other languages and join implementations. It's exactly how I'd expect it to work. Could you perhaps explain your use-case a bit more so we can try and find a different solution? Why would your right hand have a slash in it already? A cross-platform solution would look more like: let root = Path(Path.separator)
let usrBin = (root + "usr") + "bin"
let swift = usrBin + "swift" If you're supporting multiple platforms, you cannot rely on the fact that Pythonhttps://docs.python.org/3.5/library/os.path.html#os.path.join
>>> from os import path
>>> path.join("/usr/local", "/swift")
'/swift' RubyCan't find a statement in the documentation, but you can see the behaviour is the same: > Pathname.new('/usr/bin').join('/swift')
=> #<Pathname:/swift> Cocoa (NSURL)Again, I can't find a part of the documentation, but here is the behaviour. NSURL(fileURLWithPath: "/swift", relativeToURL:NSURL(fileURLWithPath: "/usr/bin"))
// --> file:///swift |
Thank you for explaining in detail. I had one counter example in mind.
Anyways, my use case is… Would you say this is not a use case for PathKit, or am I missing a better approach using PathKit? Thanks in advance for advice. |
I found this behaviour in Ruby.
I think, at least there are some demands for this style of concatination. |
Boy, I don't want to see debate about this when Apple or somebody brings Swift to Windows... (slash and backslash works both, drives' letters etc.) |
I think the following joining behavior is unnatural.
Implemented here:
PathKit/Sources/PathKit.swift
Line 668 in 62dca49
I think it is common to build paths with, left hand side not ending with "/" and right handing side starting with "/".
The text was updated successfully, but these errors were encountered: