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

Path::components strip . under the hood #16

Open
Tracked by #11
hyf0 opened this issue Feb 13, 2023 · 1 comment
Open
Tracked by #11

Path::components strip . under the hood #16

hyf0 opened this issue Feb 13, 2023 · 1 comment

Comments

@hyf0
Copy link
Owner

hyf0 commented Feb 13, 2023

This behavior is part of spec.

rust-lang/rust#23229

This makes the following code

sugar_path/src/utils.rs

Lines 29 to 31 in 41fce88

Component::CurDir => {
has_resolved_dots = true;
}

unreliable for detecting whether the dots are resolved.

@hyf0 hyf0 changed the title Path::components strip . under the hood Path::components strip . under the hood Feb 13, 2023
@hyf0 hyf0 mentioned this issue Feb 13, 2023
5 tasks
@hyf0
Copy link
Owner Author

hyf0 commented Feb 28, 2023

I'm going to keep this issue open. The issue block sugar_path to implementing on-demand normalization.

/// If there's no normalization to be done, this function will return the original `Path`.

I saw how path-absolutize handles this, and I am not going to use it.

https://github.com/magiclen/path-absolutize/blob/c2966357fced68b60852333a6c0ca01250925b22/src/unix.rs#L63-L66

https://github.com/magiclen/path-absolutize/blob/c2966357fced68b60852333a6c0ca01250925b22/src/unix.rs#L86-L88

To summarize, I would remove the current on-demand normalization feature, which cause some bugs. But the return type would still be Cow in case of reducing future changes.

@hyf0 hyf0 mentioned this issue Feb 28, 2023
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