export interface SentryPagination { previous: string hasPreviousResults: boolean hasNextResults: boolean next: string } export function parseSentryLinkHeader(header: string): SentryPagination { const links = header.split(',').map((part) => part.trim()) let result = {} as SentryPagination for (const link of links) { const match = link.match(/<([^>]+)>;\s*rel="([^"]+)";\s*results="([^"]+)";\s*cursor="([^"]+)"/) if (!match) continue const [, url, rel, results] = match if (rel === 'previous') { result.previous = url result.hasPreviousResults = results === 'true' } else if (rel === 'next') { result.next = url result.hasNextResults = results === 'true' } } return result }