api/pinterest: better regex naming

This commit is contained in:
hyperdefined 2025-06-03 19:04:05 -04:00
parent cb78dd1db9
commit 82fa660568
No known key found for this signature in database
GPG Key ID: 38C93C4835071D4A

View File

@ -3,7 +3,7 @@ import { resolveRedirectingURL } from "../url.js";
const videoRegex = /"url":"(https:\/\/v1\.pinimg\.com\/videos\/.*?)"/g;
const imageRegex = /src="(https:\/\/i\.pinimg\.com\/.*\.(jpg|gif))"/g;
const validPinRegex = /"__typename"\s*:\s*"PinNotFound"/;
const notFoundRegex = /"__typename"\s*:\s*"PinNotFound"/;
export default async function(o) {
let id = o.id;
@ -20,9 +20,9 @@ export default async function(o) {
headers: { "user-agent": genericUserAgent }
}).then(r => r.text()).catch(() => {});
const invalidPin = html.match(validPinRegex);
const invalidPin = html.match(notFoundRegex);
if (invalidPin) return { error: "fetch.empty" }
if (invalidPin) return { error: "fetch.empty" };
if (!html) return { error: "fetch.fail" };