1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-12 13:48:35 +02:00
unleash.unleash/src/lib/features/feature-search/next-link.ts
2023-10-31 14:10:31 +01:00

19 lines
397 B
TypeScript

import { Request } from 'express';
export function nextLink(
req: Pick<Request, 'baseUrl' | 'path' | 'query'>,
cursor?: string,
): string {
if (!cursor) {
return '';
}
const url = `${req.baseUrl}${req.path}?`;
const params = new URLSearchParams(req.query as Record<string, string>);
params.set('cursor', cursor);
return `${url}${params.toString()}`;
}