Files
sentry-toolkit/app/Helpers/Sentry.ts
2025-05-20 14:00:44 -04:00

28 lines
746 B
TypeScript

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
}