Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"react-icons": "5.5.0",
"react-instantsearch": "7.15.4",
"react-markdown": "10.1.0",
"redirects-in-workers": "0.0.5",
"redirects-in-workers": "0.0.7",
"rehype": "13.0.2",
"rehype-autolink-headings": "7.1.0",
"rehype-external-links": "3.0.0",
Expand Down
8 changes: 5 additions & 3 deletions worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { WorkerEntrypoint } from "cloudflare:workers";
import { generateRedirectsEvaluator } from "redirects-in-workers";
import redirectsFileContents from "../dist/__redirects";

const redirectsEvaluator = generateRedirectsEvaluator(redirectsFileContents);
const redirectsEvaluator = generateRedirectsEvaluator(redirectsFileContents, {
maxLineLength: 10_000, // Usually 2_000
maxStaticRules: 10_000, // Usually 2_000
maxDynamicRules: 2_000, // Usually 100
});

export default class extends WorkerEntrypoint<Env> {
override async fetch(request: Request) {
try {
try {
// @ts-expect-error Ignore Fetcher type mismatch
const redirect = await redirectsEvaluator(request, this.env.ASSETS);
if (redirect) {
return redirect;
Expand All @@ -24,7 +27,6 @@ export default class extends WorkerEntrypoint<Env> {
);
const redirect = await redirectsEvaluator(
new Request(forceTrailingSlashURL, request),
// @ts-expect-error Ignore Fetcher type mismatch
this.env.ASSETS,
);
if (redirect) {
Expand Down