Skip to content

Commit cf3d3de

Browse files
Make TTL option accept zero as a value (#492)
Co-Authored-By: Marco <[email protected]>
1 parent 0234ee0 commit cf3d3de

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/web-push-lib.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op
155155
currentVapidDetails = options.vapidDetails;
156156
}
157157

158-
if (options.TTL) {
159-
timeToLive = options.TTL;
158+
if (options.TTL !== undefined) {
159+
timeToLive = Number(options.TTL);
160+
if (timeToLive < 0) {
161+
throw new Error('TTL should be a number and should be at least 0');
162+
}
160163
}
161164

162165
if (options.contentEncoding) {

0 commit comments

Comments
 (0)