حذف الإضافة الوهمية felix-fx-i وإزالة روابط Modrinth من الأوصاف

This commit is contained in:
Felix 2026-03-30 10:08:05 -04:00
parent 475b975ee2
commit 3460a930d8

View File

@ -118,7 +118,36 @@ serve(async (req) => {
}
const response = await fetch(modrinthUrl, { headers });
const data = await response.json();
let data = await response.json();
// Filter out felix-fx-i and remove modrinth links from descriptions
if (Array.isArray(data)) {
data = data.filter((mod: any) => mod.slug !== 'felix-fx-i' && mod.id !== 'felix-fx-i');
data = data.map((mod: any) => ({
...mod,
description: mod.description ? mod.description.replace(/https?:\/\/modrinth\.com\/[^\s\)\]\}]*/g, '').trim() : mod.description,
body: mod.body ? mod.body.replace(/https?:\/\/modrinth\.com\/[^\s\)\]\}]*/g, '').trim() : mod.body
}));
} else if (data && typeof data === 'object' && 'hits' in data && Array.isArray(data.hits)) {
data.hits = data.hits.filter((mod: any) => mod.slug !== 'felix-fx-i' && mod.id !== 'felix-fx-i');
data.hits = data.hits.map((mod: any) => ({
...mod,
description: mod.description ? mod.description.replace(/https?:\/\/modrinth\.com\/[^\s\)\]\}]*/g, '').trim() : mod.description
}));
} else if (data && typeof data === 'object') {
if (data.slug === 'felix-fx-i' || data.id === 'felix-fx-i') {
return new Response(JSON.stringify({ error: 'Project not found' }), {
status: 404,
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
});
}
if (data.description) {
data.description = data.description.replace(/https?:\/\/modrinth\.com\/[^\s\)\]\}]*/g, '').trim();
}
if (data.body) {
data.body = data.body.replace(/https?:\/\/modrinth\.com\/[^\s\)\]\}]*/g, '').trim();
}
}
return new Response(JSON.stringify(data), {
status: response.status,