used object pattern over array
This commit is contained in:
parent
7b6454792b
commit
88097ab151
1 changed files with 9 additions and 11 deletions
|
@ -2,19 +2,17 @@ const logger = require('winston');
|
||||||
const { EMBED, BROWSER, SOCIAL } = require('../constants/request_types.js');
|
const { EMBED, BROWSER, SOCIAL } = require('../constants/request_types.js');
|
||||||
|
|
||||||
function headersMatchesSocialBotList (headers) {
|
function headersMatchesSocialBotList (headers) {
|
||||||
const socialBotList = [
|
|
||||||
'facebookexternalhit',
|
|
||||||
'Twitterbot',
|
|
||||||
];
|
|
||||||
const userAgent = headers['user-agent'];
|
const userAgent = headers['user-agent'];
|
||||||
for (let i = 0; i < socialBotList.length; i++) {
|
const socialBotList = {
|
||||||
const socialBot = socialBotList[i];
|
'facebookexternalhit': 1,
|
||||||
if (userAgent.indexOf(socialBot) >= 0) {
|
'Twitterbot' : 1,
|
||||||
logger.debug('headers on request matched this bot:', socialBot);
|
};
|
||||||
return true;
|
if (socialBotList[userAgent]) {
|
||||||
}
|
logger.debug('headers on request matched a social bot.');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clientAcceptsHtml ({accept}) {
|
function clientAcceptsHtml ({accept}) {
|
||||||
|
|
Loading…
Reference in a new issue