zzz / frontend /src /utils /extract-next-page-from-link.ts
ar08's picture
Upload 1040 files
246d201 verified
raw
history blame contribute delete
416 Bytes
/**
* Extracts the next page number from a GitHub API link header.
* @param link The GitHub API link header
* @returns The next page number or null if there is no next page
*/
export const extractNextPageFromLink = (link: string): number | null => {
const regex = /<[^>]*[?&]page=(\d+)(?:&[^>]*)?>; rel="next"/;
const match = link.match(regex);
return match ? parseInt(match[1], 10) : null;
};