diff --git a/examples b/examples index 9447e72e..0492e408 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 9447e72e087b823445b8c3e1351d28c070a8e6b1 +Subproject commit 0492e408e1b37b2ec18bcb4a4d228ab0f458f59d diff --git a/src/utils/util.js b/src/utils/util.js index e8261b76..9d934dc6 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -123,7 +123,7 @@ export default class Utils { // Fixes Javascript's float to string conversion. See https://github.com/EasyPost/easypost-node/issues/467 const correctedEventBody = Buffer.from(eventBody) .toString('utf8') - .replace(/("weight":)(\d+)(?!\.\d)/g, '$1$2.0'); + .replace(/("weight":\s*)(\d+)(\s*)(?=,|\})/g, '$1$2.0'); const expectedSignature = crypto .createHmac('sha256', encodedSecret) diff --git a/test/services/webhook.test.js b/test/services/webhook.test.js index e60edefd..57fc2ad3 100644 --- a/test/services/webhook.test.js +++ b/test/services/webhook.test.js @@ -98,9 +98,7 @@ describe('Webhook Service', function () { ); expect(webhookBody.description).to.equal('tracker.updated'); - // JS converts this from `136.0` in the response to `136` on the user's end which is unfortunate; however, we - // compare signatures with the correct number prior to JSON parsing it and returning it to the user. - expect(webhookBody.result.weight).to.equal(136.0); + expect(webhookBody.result.weight).to.equal(614.4); // Ensure we convert floats properly }); it('throws an error when a webhook secret is a differing length', function () {