diff --git a/src/modules/processing/services/tumblr.js b/src/modules/processing/services/tumblr.js index 7ae7336c..f978e5a4 100644 --- a/src/modules/processing/services/tumblr.js +++ b/src/modules/processing/services/tumblr.js @@ -1,9 +1,12 @@ +import psl from "psl"; import { genericUserAgent } from "../../config.js"; export default async function(obj) { - let html = await fetch(`https://${ - obj.user ? obj.user : obj.url.split('.')[0].replace('https://', '') - }.tumblr.com/post/${obj.id}`, { + const { subdomain } = psl.parse(obj.url); + if (subdomain?.includes('.')) + return { error: 'ErrorBrokenLink' } + + let html = await fetch(`https://${obj.user ?? subdomain}.tumblr.com/post/${obj.id}`, { headers: { "user-agent": genericUserAgent } }).then((r) => { return r.text() }).catch(() => { return false });