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

parse_size doesn't recognize binary units that end with "byte," "bytes," or "s" #26

Open
troyhoffman opened this issue Apr 13, 2018 · 2 comments

Comments

@troyhoffman
Copy link

parse_size('10 MiB') returns 10485760, as expected. However, parse_size('10 MiBs') returns 10000000, as does parse_size('10 MiByte') or parse_size('10 MiBytes').

In all cases, it should be 10485760.

@gdevenyi
Copy link

This problem extends to the SI power-of-two suffixes such as "gibibyte". "gibibyte" works, "gibibytes" doesn't

xolox added a commit that referenced this issue Feb 16, 2020
@xolox
Copy link
Owner

xolox commented Feb 16, 2020

I've just released humanfriendly 7.1 which changes the situation slightly: If a trailing s was all that previously prevented correct matching then the match should now succeed. This tackles the 10 MiBs case and more generally the second comment here.

The 10 MiByte and 10 MiBytes cases are not (yet) handled as suggested because I'm divided about whether I want or should support this much diversity. I'd never seen these used before and Google reports about 10K matches, which is not exactly convincing 😇.

In any case I'll leave this open to enable discussion on this topic.

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

3 participants