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:
parent
68d5634c64
commit
8c7cd6832e
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue