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

Repeated forward slashes become absolute paths #208

Closed
g5t opened this issue Apr 24, 2024 · 2 comments · Fixed by #209
Closed

Repeated forward slashes become absolute paths #208

g5t opened this issue Apr 24, 2024 · 2 comments · Fixed by #209
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@g5t
Copy link
Contributor

g5t commented Apr 24, 2024

Following up on #204 and the fix in #205, I noticed that a path with repeated forward slashes will silently ignore any valid path before the last such '/' and treat the rest of the path specification as an absolute path. E.g., a NeXus HDF5 file with an NXinstrument group at /entry/instrument opened as file will pass the following assert statement

assert id(file['/entry/instrument']) == id(file['/entry//entry/instrument'])

this behavior is contrary to file system paths under unix-like systems which treat repeated path separators as if they were singular.

@jl-wynen jl-wynen added the bug Something isn't working label Apr 24, 2024
@MridulS
Copy link
Member

MridulS commented Apr 24, 2024

Maybe we can use pathlib to santize these things? I know they aren't path objects, but it should take care of all these corner cases.

@jl-wynen
Copy link
Member

Yes:

PurePosixPath('/entry//entry/instrument').as_posix()

Also takes care of the final slash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants