diff --git a/src/GoTrueAdminApi.ts b/src/GoTrueAdminApi.ts index ddd5149d3..90c17850a 100644 --- a/src/GoTrueAdminApi.ts +++ b/src/GoTrueAdminApi.ts @@ -194,10 +194,14 @@ export default class GoTrueAdminApi { const total = response.headers.get('x-total-count') ?? 0 const links = response.headers.get('link')?.split(',') ?? [] if (links.length > 0) { + const regex = /page=(\d+)(?=&)[^>]*>; rel="(\w+)"/ links.forEach((link: string) => { - const page = parseInt(link.split(';')[0].split('=')[1].substring(0, 1)) - const rel = JSON.parse(link.split(';')[1].split('=')[1]) - pagination[`${rel}Page`] = page + const match = regex.exec(link.trim()) + if (match) { + const page = parseInt(match[1], 10) + const rel = match[2] + pagination[`${rel}Page`] = page + } }) pagination.total = parseInt(total)