Skip to content

Commit

Permalink
fix: Incorrectly attempting to send body in GET, DELETE requests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaker6 authored Feb 8, 2025
1 parent 0999242 commit 7ca2681
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ module.exports = function (dependencies) {
responseData += data;
});

if (Object.keys(notification.body).length > 0) {
if (notification.body !== '{}') {
request.write(notification.body);
}

Expand Down
4 changes: 2 additions & 2 deletions test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ describe('ManageChannelsClient', () => {
const mockHeaders = { 'apns-channel-id': channel, ...additionalHeaderInfo };
const mockNotification = {
headers: mockHeaders,
body: {},
body: '{}',
};
const bundleId = BUNDLE_ID;
const result = await client.write(mockNotification, bundleId, 'channels', 'delete');
Expand Down Expand Up @@ -1822,7 +1822,7 @@ describe('ManageChannelsClient', () => {
const mockHeaders = { 'apns-request-id': requestId };
const mockNotification = {
headers: mockHeaders,
body: {},
body: '{}',
};
const bundleId = BUNDLE_ID;
const result = await client.write(mockNotification, bundleId, 'allChannels', 'get');
Expand Down
5 changes: 5 additions & 0 deletions test/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ describe('Notification', function () {
expect(note.topic).to.equal('io.apn.node');
expect(compiledOutput()).to.have.nested.deep.property('aps.badge', 5);
});

it('no initialization values', function () {
expect(note.compile()).to.equal('{}');
expect(compiledOutput()).to.be.empty;
});
});

describe('rawPayload', function () {
Expand Down

0 comments on commit 7ca2681

Please sign in to comment.