tumblr: stricter subdomain parsing
This commit is contained in:
parent
149c16abbb
commit
f9feaa41ce
1 changed files with 6 additions and 3 deletions
|
@ -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 });
|
||||
|
||||
|
|
Loading…
Reference in a new issue