Code review: use function arrow properly

This commit is contained in:
Raymond Hill 2019-05-01 06:35:47 -04:00
parent 016625465e
commit 99212e3264
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 9 deletions

View File

@ -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 };
}
};