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

Issues with Windows drive letters, absolute() and parent() #489

Closed
ollbx opened this issue May 7, 2023 · 2 comments
Closed

Issues with Windows drive letters, absolute() and parent() #489

ollbx opened this issue May 7, 2023 · 2 comments

Comments

@ollbx
Copy link

ollbx commented May 7, 2023

In Windows, "c:" does not seem to be considered an absolute path:

require("plenary.path"):new("c:"):is_absolute()
-- returns: false
require("plenary.path"):new("c:"):absolute()
-- returns: the cwd

This changes, when a trailing \ is added:

require("plenary.path"):new("c:\\"):is_absolute()
-- returns: true
require("plenary.path"):new("c:\\"):absolute()
-- returns: "c:\\"

That may be fine (depending on definitions). However when using Path:parent(), no trailing slash is added, which leads to unexpected results:

require("plenary.path"):new("c:\\test\\"):parent().filename
-- returns: "c:"
require("plenary.path"):new("c:\\test\\"):parent():absolute()
-- returns: the cwd instead of "c:\\"

The solution seems to be to either make sure that parent() always appends a path separator (which would seem reasonable to me, to distinguish that the path is for a directory and not for a file) or "c:" would need to be detected as the filesystem root and handled accordingly by is_absolute() and absolute().

@Conni2461
Copy link
Collaborator

Conni2461 commented Jan 29, 2024

might also be fixed with this commit 4f71c0c now

@ollbx
Copy link
Author

ollbx commented Feb 6, 2024

Yes the issue seems to be fixed for me.

@ollbx ollbx closed this as completed Feb 6, 2024
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

2 participants