Skip to content

Commit 31d87ed

Browse files
authored
Convert lastModified date to GMT string per spec (#275)
1 parent 09ebdf9 commit 31d87ed

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

source/lib/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function getNotificationCount() {
126126
const {headers, json: notifications} = await getNotificationResponse({maxItems: 1});
127127

128128
const interval = Number(headers.get('X-Poll-Interval'));
129-
const lastModified = (new Date(headers.get('Last-Modified'))).toISOString();
129+
const lastModified = (new Date(headers.get('Last-Modified'))).toGMTString();
130130
const linkHeader = headers.get('Link');
131131

132132
if (linkHeader === null) {

source/lib/notifications-service.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function playNotificationSound() {
125125
}
126126

127127
export async function checkNotifications(lastModified) {
128-
let notifications = await getNotifications({lastModified});
128+
let notifications = await getNotifications({lastModified: lastModified.toGMTString()});
129129
const {showDesktopNotif, playNotifSound, filterNotifications} = await optionsStorage.getAll();
130130

131131
if (filterNotifications) {

test/api-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ test.serial('#getNotificationCount promise resolves response of 0 notifications
154154
global.fetch = fakeFetch();
155155

156156
const response = await service.getNotificationCount();
157-
t.deepEqual(response, {count: 0, interval: 60, lastModified: '1970-01-01T00:00:00.000Z'});
157+
t.deepEqual(response, {count: 0, interval: 60, lastModified: 'Thu, 01 Jan 1970 00:00:00 GMT'});
158158
});
159159

160160
test.serial('#getNotificationCount promise resolves response of N notifications according to Link header', async t => {
@@ -168,7 +168,7 @@ test.serial('#getNotificationCount promise resolves response of N notifications
168168
}
169169
});
170170

171-
t.deepEqual(await service.getNotificationCount(), {count: 2, interval: 60, lastModified: '1970-01-01T00:00:00.000Z'});
171+
t.deepEqual(await service.getNotificationCount(), {count: 2, interval: 60, lastModified: 'Thu, 01 Jan 1970 00:00:00 GMT'});
172172

173173
global.fetch = fakeFetch({
174174
headers: {
@@ -179,7 +179,7 @@ test.serial('#getNotificationCount promise resolves response of N notifications
179179
}
180180
});
181181

182-
t.deepEqual(await service.getNotificationCount(), {count: 3, interval: 60, lastModified: '1970-01-01T00:00:00.000Z'});
182+
t.deepEqual(await service.getNotificationCount(), {count: 3, interval: 60, lastModified: 'Thu, 01 Jan 1970 00:00:00 GMT'});
183183
});
184184

185185
test.serial('#makeApiRequest returns rejected promise for 4xx status codes', async t => {

0 commit comments

Comments
 (0)