tumblr: stricter subdomain parsing

This commit is contained in:
dumbmoron 2023-12-14 22:43:36 +00:00
parent 149c16abbb
commit f9feaa41ce
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F

View file

@ -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 });