From d7073c6d5e08e46b3bfa72eaba8dbb996032b106 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Wed, 6 Nov 2024 00:11:28 +0900 Subject: [PATCH] Skip link header if it is the final page --- megalodon/src/friendica.ts | 3 +++ megalodon/src/mastodon.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/megalodon/src/friendica.ts b/megalodon/src/friendica.ts index 3de3b6cf..bc81e088 100644 --- a/megalodon/src/friendica.ts +++ b/megalodon/src/friendica.ts @@ -487,6 +487,9 @@ export default class Friendica implements MegalodonInterface { converted = Object.assign({}, converted, { data: [...converted.data, ...nextRes.data.map(a => FriendicaAPI.Converter.account(a))] }) + if (nextRes.headers.link === undefined) { + break + } parsed = parseLinkHeader(nextRes.headers.link) if (sleep_ms) { await new Promise(converted => setTimeout(converted, sleep_ms)) diff --git a/megalodon/src/mastodon.ts b/megalodon/src/mastodon.ts index 744cdb76..17ed007a 100644 --- a/megalodon/src/mastodon.ts +++ b/megalodon/src/mastodon.ts @@ -564,6 +564,9 @@ export default class Mastodon implements MegalodonInterface { converted = Object.assign({}, converted, { data: [...converted.data, ...nextRes.data.map(a => MastodonAPI.Converter.account(a))] }) + if (nextRes.headers.link === undefined) { + break + } parsed = parseLinkHeader(nextRes.headers.link) if (sleep_ms) { await new Promise(converted => setTimeout(converted, sleep_ms))