Skip to content

Commit 4177e7f

Browse files
Replace indexOf with other methods (#773)
1 parent 8921c4b commit 4177e7f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/web-push-lib.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op
131131
const optionKeys = Object.keys(options);
132132
for (let i = 0; i < optionKeys.length; i += 1) {
133133
const optionKey = optionKeys[i];
134-
if (validOptionKeys.indexOf(optionKey) === -1) {
134+
if (!validOptionKeys.includes(optionKey)) {
135135
throw new Error('\'' + optionKey + '\' is an invalid option. '
136136
+ 'The valid options are [\'' + validOptionKeys.join('\', \'')
137137
+ '\'].');
@@ -259,8 +259,8 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op
259259
requestDetails.headers['Content-Length'] = 0;
260260
}
261261

262-
const isGCM = subscription.endpoint.indexOf('https://android.googleapis.com/gcm/send') === 0;
263-
const isFCM = subscription.endpoint.indexOf('https://fcm.googleapis.com/fcm/send') === 0;
262+
const isGCM = subscription.endpoint.startsWith('https://android.googleapis.com/gcm/send');
263+
const isFCM = subscription.endpoint.startsWith('https://fcm.googleapis.com/fcm/send');
264264
// VAPID isn't supported by GCM hence the if, else if.
265265
if (isGCM) {
266266
if (!currentGCMAPIKey) {

0 commit comments

Comments
 (0)