From 5928b21feee9fa4a51debbdd1bf2760bff660096 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Mon, 18 Dec 2023 12:44:18 +0000 Subject: [PATCH] tumblr: fix priority of subdomain/segment for username --- src/modules/processing/services/tumblr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/processing/services/tumblr.js b/src/modules/processing/services/tumblr.js index 90eb45c2..08b3a3e2 100644 --- a/src/modules/processing/services/tumblr.js +++ b/src/modules/processing/services/tumblr.js @@ -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 });