radarlabs / radar-sdk-js

Web JavaScript SDK for Radar, the leading geofencing and location tracking platform
https://radar.com
Apache License 2.0
42 stars 11 forks source link

Hotfix null and undefined check for session storage #76

Closed jaspk06 closed 1 year ago

jaspk06 commented 1 year ago

Issue

When setting items in session storage, null and undefined values were being set as strings "null", "undefined".

According to the existing logic in Storage.getItem, these values weren't intended to be stored in the first place. This check in Storage.getItem is never hit since every value pulled from storage are strings.

https://github.com/radarlabs/radar-sdk-js/blob/2cc470776b8989bf5ae02e711056ecce7ec1f229/src/storage.js#L53-L64

This caused an error in every API request made in #75. Calling Radar.setHost(apiHost) would set the url to be apiHost/undefined/... when it should've defaulted to apiHost/v1/...