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";
|
import { genericUserAgent } from "../../config.js";
|
||||||
|
|
||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let html = await fetch(`https://${
|
const { subdomain } = psl.parse(obj.url);
|
||||||
obj.user ? obj.user : obj.url.split('.')[0].replace('https://', '')
|
if (subdomain?.includes('.'))
|
||||||
}.tumblr.com/post/${obj.id}`, {
|
return { error: 'ErrorBrokenLink' }
|
||||||
|
|
||||||
|
let html = await fetch(`https://${obj.user ?? subdomain}.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