tumblr: fix priority of subdomain/segment for username
This commit is contained in:
parent
18a3c06a9e
commit
5928b21fee
1 changed files with 4 additions and 2 deletions
|
@ -2,11 +2,13 @@ import psl from "psl";
|
||||||
import { genericUserAgent } from "../../config.js";
|
import { genericUserAgent } from "../../config.js";
|
||||||
|
|
||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
const { subdomain } = psl.parse(obj.url.hostname);
|
let { subdomain } = psl.parse(obj.url.hostname);
|
||||||
if (subdomain?.includes('.'))
|
if (subdomain?.includes('.'))
|
||||||
return { error: ['ErrorBrokenLink', 'tumblr'] }
|
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 }
|
headers: { "user-agent": genericUserAgent }
|
||||||
}).then((r) => { return r.text() }).catch(() => { return false });
|
}).then((r) => { return r.text() }).catch(() => { return false });
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue