Only accept HTML <link rel="alternate"> on success

(cherry picked from commit 6ea48be84abdab66301a957c27dd5d84886dfb36)
This commit is contained in:
Julia Johannesen
2024-09-22 17:13:24 -04:00
committed by kakkokari-gtyih
parent 9d3a331286
commit 59adc13b03

View File

@@ -205,7 +205,12 @@ export class ApRequestService {
//#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき
const contentType = res.headers.get('content-type');
if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate === true) {
if (
res.status >= 200
&& res.status <= 299
&& (contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html'
&& _followAlternate === true
) {
const html = await res.text();
const { window, happyDOM } = new Window({
settings: {