tumblr: fix priority of subdomain/segment for username

This commit is contained in:
dumbmoron 2023-12-18 12:44:18 +00:00
parent 18a3c06a9e
commit 5928b21fee
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F

View file

@ -2,11 +2,13 @@ import psl from "psl";
import { genericUserAgent } from "../../config.js";
export default async function(obj) {
const { subdomain } = psl.parse(obj.url.hostname);
let { subdomain } = psl.parse(obj.url.hostname);
if (subdomain?.includes('.'))
return { error: ['ErrorBrokenLink', 'tumblr'] }
else if (subdomain === 'www')
subdomain = undefined;
let html = await fetch(`https://${obj.user ?? subdomain}.tumblr.com/post/${obj.id}`, {
let html = await fetch(`https://${subdomain ?? obj.user}.tumblr.com/post/${obj.id}`, {
headers: { "user-agent": genericUserAgent }
}).then((r) => { return r.text() }).catch(() => { return false });