@@ -6,13 +6,12 @@ import { cors } from "@elysiajs/cors";
6
6
import { helmet } from "elysia-helmet" ;
7
7
import { ip } from "elysia-ip" ;
8
8
import { UAParser } from "ua-parser-js" ;
9
- import { getIPLocation } from "./functions/utils" ;
9
+ import { getIPLocation , isPotentialBot } from "./functions/utils" ;
10
10
import { insertRedirect } from "./functions/redirects" ;
11
11
import { redirectsRoutes } from "./routes/redirects" ;
12
12
import bearer from "@elysiajs/bearer" ;
13
13
import { demoRoutes } from "./routes/demo" ;
14
14
import { NOT_FOUND_PAGE , PERSONAL_WEBSITE } from "./utils/constants" ;
15
- import { isbot } from "isbot" ;
16
15
17
16
const app = new Elysia ( )
18
17
. use ( cors ( ) )
@@ -74,11 +73,12 @@ const app = new Elysia()
74
73
// Save analytics data after redirection, for performance reasons
75
74
async afterResponse ( { params, ip, headers } ) {
76
75
const link = await getLink ( params . code ) ;
77
- if ( ! link || isbot ( headers [ "user-agent" ] ) ) {
76
+ const userAgent = headers [ "user-agent" ] ;
77
+ if ( ! link || isPotentialBot ( userAgent ) ) {
78
78
return ;
79
79
}
80
80
81
- const parserResult = new UAParser ( headers [ "user-agent" ] ) . getResult ( ) ;
81
+ const parserResult = new UAParser ( userAgent ) . getResult ( ) ;
82
82
const lang = headers [ "accept-language" ] ?. split ( "," ) [ 0 ] ;
83
83
const loc = await getIPLocation ( ip ) ;
84
84
await insertRedirect ( {
0 commit comments