visionmedia / bytes.js

node byte string parser
MIT License
458 stars 57 forks source link

Fix parsing of byte strings lacking leading 0 before decimal #63

Open TylerAldrich opened 1 year ago

TylerAldrich commented 1 year ago

I noticed the following issue:

> bytes.parse('.25GB');
null
> bytes.parse('0.25GB');
268435456

where if a leading 0 is not supplied, null is always returned. I updated the parse regex to look for 0 or more leading digits so that '.25GB' could be parsed correctly, and added some tests to verify that omitting a leading 0 returns the same result as supplying one.

TylerAldrich commented 1 year ago

FYI @dougwilson - It looks like when the actions were running there was an issue with downloading https://iojs.org/dist/v2.5.0/iojs-v2.5.0.tar.xz that appears to be fixed (the link itself is working for me now, was erroring 2 days ago).