tumblr: render error template for broken links

This commit is contained in:
dumbmoron 2023-12-14 23:05:57 +00:00
parent 81e68c37f5
commit 34d8333d72
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F

View file

@ -4,7 +4,7 @@ import { genericUserAgent } from "../../config.js";
export default async function(obj) { export default async function(obj) {
const { subdomain } = psl.parse(obj.url.hostname); const { subdomain } = psl.parse(obj.url.hostname);
if (subdomain?.includes('.')) if (subdomain?.includes('.'))
return { error: 'ErrorBrokenLink' } return { error: ['ErrorBrokenLink', 'tumblr'] }
let html = await fetch(`https://${obj.user ?? subdomain}.tumblr.com/post/${obj.id}`, { let html = await fetch(`https://${obj.user ?? subdomain}.tumblr.com/post/${obj.id}`, {
headers: { "user-agent": genericUserAgent } headers: { "user-agent": genericUserAgent }