mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 03:08:30 +00:00
fix(snapchat): small fixes
This commit is contained in:
parent
2110cae030
commit
a0465feb85
@ -64,7 +64,7 @@ export default async function(obj) {
|
||||
let pathname;
|
||||
if (obj.url.hostname === '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;
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ export function cleanHTML(html) {
|
||||
return clean
|
||||
}
|
||||
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'))
|
||||
return r.headers.get('location');
|
||||
}).catch(() => null);
|
||||
|
Loading…
Reference in New Issue
Block a user