mirror of
https://github.com/AMNatty/Mastodon-Circles.git
synced 2024-11-22 02:57:25 -07:00
Fix the return type in MastodonApiClient::getNextPage
This commit is contained in:
parent
473be10607
commit
9c681cd4f2
1 changed files with 9 additions and 5 deletions
|
@ -360,7 +360,7 @@ class MastodonApiClient extends ApiClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Headers} headers
|
* @param {Headers} headers
|
||||||
* @return {URL?} request URL for next page or null
|
* @return {URL | null} request URL for next page or null
|
||||||
*/
|
*/
|
||||||
static getNextPage(headers)
|
static getNextPage(headers)
|
||||||
{
|
{
|
||||||
|
@ -379,10 +379,14 @@ class MastodonApiClient extends ApiClient {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
for (const link of links.split(",")) {
|
for (const link of links.split(",")) {
|
||||||
const p = link.split(";").map(s => s.trim());
|
const [url_raw, rel] = link.split(";").map(s => s.trim());
|
||||||
if (p.length == 2 && p[1] === 'rel="next"') {
|
if (url_raw && rel === 'rel="next"') {
|
||||||
// Remove enclosing angle brackets <...>
|
try {
|
||||||
return p[0].substring(1, p[0].length - 1);
|
// Remove enclosing angle brackets <...>
|
||||||
|
return new URL(url_raw.substring(1, url_raw.length - 1));
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Invalid URL: ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue