fix(snapchat): small fixes

This commit is contained in:
Snazzah 2024-05-15 20:16:07 -05:00
parent 2110cae030
commit a0465feb85
No known key found for this signature in database
GPG Key ID: EA479766A94CEB61
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ export default async function(obj) {
let pathname; let pathname;
if (obj.url.hostname === 't.snapchat.com' && obj.shortLink) { if (obj.url.hostname === 't.snapchat.com' && obj.shortLink) {
const link = await getRedirectingURL(`https://t.snapchat.com/${obj.shortLink}`); const link = await getRedirectingURL(`https://t.snapchat.com/${obj.shortLink}`);
if (link && !link.startsWith('https://www.snapchat.com/')) return { error: 'ErrorCouldntFetch' }; if (!link || !link.startsWith('https://www.snapchat.com/')) return { error: 'ErrorCouldntFetch' };
pathname = new URL(link).pathname; pathname = new URL(link).pathname;
} }

View File

@ -136,7 +136,7 @@ export function cleanHTML(html) {
return clean return clean
} }
export async function getRedirectingURL(url) { export async function getRedirectingURL(url) {
return await fetch(url, { redirect: 'manual' }).then((r) => { return fetch(url, { redirect: 'manual' }).then((r) => {
if ([301, 302, 303].includes(r.status) && r.headers.has('location')) if ([301, 302, 303].includes(r.status) && r.headers.has('location'))
return r.headers.get('location'); return r.headers.get('location');
}).catch(() => null); }).catch(() => null);