api/facebook: handle URLs with query parameters in share links

This commit is contained in:
Aholicknight 2024-11-25 18:55:58 -06:00
parent 5be8789576
commit 943fe7991e

View file

@ -29,6 +29,12 @@ export default async function({ id, shareType, shortLink }) {
if (shareType) url = `https://web.facebook.com/share/${shareType}/${id}`;
if (shortLink) url = await resolveUrl(`https://fb.watch/${shortLink}`);
// Handle URLs with query parameters like ?mibextid
if (url.includes('?')) {
const urlObj = new URL(url);
url = urlObj.origin + urlObj.pathname;
}
const html = await fetch(url, { headers })
.then(r => r.text())
.catch(() => false);
@ -54,4 +60,4 @@ export default async function({ id, shareType, shortLink }) {
filename: `${baseFilename}.mp4`,
audioFilename: `${baseFilename}_audio`,
};
}
}