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

Treat empty paths correctly #29

Merged
merged 3 commits into from Dec 3, 2021
Merged

Treat empty paths correctly #29

merged 3 commits into from Dec 3, 2021

Conversation

udoprog
Copy link
Owner

@udoprog udoprog commented Dec 3, 2021

The way that to_path and to_logical_path reacts to empty paths wasn't properly specified nor implemented. The current behavior ends up being rather on, in that the main separator is added so that the following would produce an absolute path on Linux:

let path = RelativePath::new("foo/bar").to_path("");
assert_eq!(Path::new("/foo/bar"), path);

This is clearly dysfunctional and contrary to what this crate is trying to accomplish. So this patch changes this behavior so that we only add the main separator for cases where the from path is non-empty.

What we then get instead is:

let path = RelativePath::new("foo/bar").to_path("");
assert_eq!(Path::new("foo/bar"), path);

@udoprog udoprog added the bug label Dec 3, 2021
@udoprog udoprog merged commit d420718 into main Dec 3, 2021
@udoprog udoprog deleted the empty-paths branch December 3, 2021 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant