Skip to content

Commit

Permalink
Merge pull request #2 from omrilotan/isbot_upgrade
Browse files Browse the repository at this point in the history
Upgrade isbot major version
  • Loading branch information
talentlessguy authored Jan 4, 2024
2 parents f39fb8e + 608057b commit 9899576
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"author": "v1rtl",
"license": "MIT",
"dependencies": {
"isbot": "^3.6.10"
"isbot": "^4.1.1"
},
"scripts": {
"build": "rollup -c",
Expand Down
14 changes: 9 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IncomingMessage as Request } from 'http'
import detectBot from 'isbot'
import { isbot, isbotMatch } from 'isbot'

export interface RequestWithBotDetector extends Request {
isBot: boolean
Expand All @@ -20,13 +20,13 @@ export function botDetector() {
isBot: {
get: () => {
if (typeof bot === 'boolean') return bot
return (bot = detectBot(agent))
return (bot = isbot(agent))
}
},
botName: {
get: () => {
if (!req.isBot) name = null
if (typeof name === 'undefined') name = detectBot.find(agent)
if (typeof name === 'undefined') name = isbotMatch(agent)

return name || undefined
}
Expand Down

0 comments on commit 9899576

Please sign in to comment.