fix(route/phoronix): Use `ofetch` and `parseString` for reliable feed fetching (#20543)

The `rss-parser`'s internal `parseURL` method can fail with an "Error:
Non-whitespace before first tag" on feeds that are gzipped or contain a
Byte Order Mark (BOM), as it lacks robust decompression and encoding
handling.

This change switches the Phoronix route to:

Fetch the raw XML string using `ofetch`, which handles compression and
encoding correctly.

Pass the resulting clean string to `parser.parseString()`.

This resolves the parsing issue and ensures the route is reliable.
This commit is contained in:
IChengHo 2025-11-21 15:33:29 -05:00 committed by GitHub
parent 68d5634c64
commit 8c7cd6832e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import cache from '@/utils/cache';
import parser from '@/utils/rss-parser';
import { load } from 'cheerio';
@ -17,7 +18,8 @@ const baseUrl = 'https://www.phoronix.com';
const rssUrl = `${baseUrl}/rss.php`;
const feedFetch = async () => {
const feed = await parser.parseURL(rssUrl);
const feedStr = await ofetch(rssUrl);
const feed = await parser.parseString(feedStr);
return {
title: feed.title,
link: feed.link,