From 99212e3264bc700ed79b84ee7314542066d1fb69 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 1 May 2019 06:35:47 -0400 Subject: [PATCH] Code review: use function arrow properly --- platform/chromium/vapi-background.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 09a274cb7..fca2df011 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -1043,24 +1043,19 @@ vAPI.messaging.broadcast = function(message) { // A specific secret can be used for at most one second. vAPI.warSecret = (function() { - let lastSecretTime = 0; - let lastSecretPtr = 0; - const generateSecret = ( ) => { - lastSecretTime = Date.now(); return Math.floor(Math.random() * 982451653 + 982451653).toString(36) + Math.floor(Math.random() * 982451653 + 982451653).toString(36); }; - const secrets = [ generateSecret(), generateSecret(), generateSecret() ]; const root = vAPI.getURL('/'); + const secrets = [ generateSecret(), generateSecret(), generateSecret() ]; + let lastSecretPtr = 0; + let lastSecretTime = Date.now(); const guard = function(details) { const url = details.url; - const r = secrets.every(secret => { - return url.indexOf(`?secret=${secret}`) === -1; - }); - if ( r ) { + if ( secrets.every(secret => url.indexOf(`?secret=${secret}`) === -1) ) { return { redirectUrl: root }; } };