I was trying to parse some fastresume files(encoded via Bencode). When decode from bytes like { foo: -123 }, an error "expected digit, got 0x2d" was thrown. I looked into the code, found that the readInt function does not treat Lit.MINUS as readFloat dose.
I looked up on Wikipedia, and found that the negative integer seems been described in spec.
I'm not sure it's on purpose or I missing something. I add a few code in the readInt function to make it run, but only on locally right now. Also, I tested the added code using following test case.
I was trying to parse some fastresume files(encoded via Bencode). When decode from bytes like
{ foo: -123 }
, an error "expected digit, got 0x2d" was thrown. I looked into the code, found that thereadInt
function does not treat Lit.MINUS asreadFloat
dose.https://github.com/thi-ng/umbrella/blob/07105097d48766e456b4d2a15468d7fef9483fe5/packages/bencode/src/decode.ts#L123-L129
I looked up on Wikipedia, and found that the negative integer seems been described in spec.
I'm not sure it's on purpose or I missing something. I add a few code in the readInt function to make it run, but only on locally right now. Also, I tested the added code using following test case.