summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/fastify-hook-handlers.ts
blob: 49a48f6a6b000b79ff84c8b16ed33e87ee04e8de (plain)
1
2
3
4
5
6
7
8
9
import type { onRequestHookHandler } from 'fastify';

export const handleRequestRedirectToOmitSearch: onRequestHookHandler = (request, reply, done) => {
	const index = request.url.indexOf('?');
	if (~index) {
		reply.redirect(301, request.url.slice(0, index));
	}
	done();
};