Skip to content

Commit

Permalink
fix isbot?
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgi committed Sep 17, 2024
1 parent d2a3721 commit b6c9aef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PassThrough } from "node:stream";
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import * as isbotModule from "isbot";
import { isbot } from "isbot";
import { renderToPipeableStream } from "react-dom/server";

export function handleError(error: unknown, { request }: { request: Request }) {
Expand Down Expand Up @@ -40,17 +40,7 @@ function isBotRequest(userAgent: string | null) {
return false;
}

// isbot >= 3.8.0, >4
if ("isbot" in isbotModule && typeof isbotModule.isbot === "function") {
return isbotModule.isbot(userAgent);
}

// isbot < 3.8.0
if ("default" in isbotModule && typeof isbotModule.default === "function") {
return isbotModule.default(userAgent);
}

return false;
return isbot(userAgent);
}

function handleBotRequest(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"graphql-request": "^7.1.0",
"human-number": "^2.0.4",
"ioredis": "^5.3.2",
"isbot": "^5.1.0",
"isbot": "^5.1.17",
"js-abbreviation-number": "^1.4.0",
"lucide-react": "^0.317.0",
"mime-types": "^2.1.35",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

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

0 comments on commit b6c9aef

Please sign in to comment.