Files
stats/apps/api/src/bots/index.ts
2024-03-11 13:15:44 +01:00

20 lines
302 B
TypeScript

import bots from './bots';
export function isBot(ua: string) {
const res = bots.find((bot) => {
if (new RegExp(bot.regex).test(ua)) {
return true;
}
return false;
});
if (!res) {
return null;
}
return {
name: res.name,
type: res.category || 'Unknown',
};
}