flitbit / json-ptr

A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.
MIT License
91 stars 28 forks source link

get blows up when trying to extract path from a null value - failed gracefully in 1.2.0 #36

Closed CarolynWebster closed 3 years ago

CarolynWebster commented 3 years ago

I recently upgraded to 1.3.1 so I could use this library with Typescript, but it seems like what used to fail gracefully is now blowing up.

If I have an object like:

{
    id: 1234,
    employee: null,
    created_on: 2021-05-11
}

With 1.2.0 - if I tried to get the field "/employee/st_price" - it would fail gracefully and return undefined With 1.3.1 - it blows up saying it can't find "st_price" in null

Uncaught TypeError: Cannot read property 'st_price' of null
    at JsonPointer.eval (eval at compilePointerDereference (util.js?06b3:1), <anonymous>:5:17)
    at JsonPointer.get (pointer.js?05e6:131)
    at Function.get (pointer.js?05e6:81)
    ....
cerebralkungfu commented 3 years ago

Please confirm with today's release v2.1.0. I'll create a proof under examples/issues after a while if I don't hear back.

CarolynWebster commented 3 years ago

I will test it out this week - thanks for the quick reply.

cerebralkungfu commented 3 years ago

Fixed in v2.1.1

CarolynWebster commented 3 years ago

The issue is resolved in 2.1.1. I am going to go with 2.2.0 since it fixes the extra console log that was in the util file. Thanks for taking care of this quickly! Excited to upgrade and get the typescript support. Appreciate you and your work on this library! 🙂