mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-22 16:03:29 +10:00
fix: monkey patch a nitro build error (resolves #3065)
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
"drizzle-zod": "1.0.0-beta.14-a36c63d",
|
||||
"es-toolkit": "^1.46.1",
|
||||
"ioredis": "^5.10.1",
|
||||
"jsdom": "^29.1.1",
|
||||
"linkedom": "^0.18.12",
|
||||
"ollama-ai-provider-v2": "^3.5.1",
|
||||
"react": "^19.2.6",
|
||||
"resumable-stream": "^2.2.12",
|
||||
@@ -53,7 +53,6 @@
|
||||
"devDependencies": {
|
||||
"@reactive-resume/config": "workspace:*",
|
||||
"@types/bcrypt": "^6.0.0",
|
||||
"@types/jsdom": "^28.0.3",
|
||||
"@typescript/native-preview": "7.0.0-dev.20260514.1",
|
||||
"typescript": "^6.0.3"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { lookup } from "node:dns/promises";
|
||||
import { Readability } from "@mozilla/readability";
|
||||
import { JSDOM } from "jsdom";
|
||||
import { parseHTML } from "linkedom";
|
||||
import { Agent, fetch as undiciFetch } from "undici";
|
||||
import { env } from "@reactive-resume/env/server";
|
||||
import { isPrivateOrLoopbackHost } from "@reactive-resume/utils/url-security.node";
|
||||
@@ -41,21 +41,22 @@ function compactText(value: string) {
|
||||
}
|
||||
|
||||
function extractReadableHtml(html: string, url: string) {
|
||||
const dom = new JSDOM(html, { url });
|
||||
const { document } = parseHTML(html);
|
||||
|
||||
try {
|
||||
const article = new Readability(dom.window.document).parse();
|
||||
const content = compactText(article?.textContent ?? "");
|
||||
Object.defineProperties(document, {
|
||||
baseURI: { value: url },
|
||||
documentURI: { value: url },
|
||||
});
|
||||
|
||||
if (content.length < 160) throw new Error("URL_READABILITY_FAILED");
|
||||
const article = new Readability(document).parse();
|
||||
const content = compactText(article?.textContent ?? "");
|
||||
|
||||
return {
|
||||
title: article?.title ? compactText(article.title) : null,
|
||||
content,
|
||||
};
|
||||
} finally {
|
||||
dom.window.close();
|
||||
}
|
||||
if (content.length < 160) throw new Error("URL_READABILITY_FAILED");
|
||||
|
||||
return {
|
||||
title: article?.title ? compactText(article.title) : null,
|
||||
content,
|
||||
};
|
||||
}
|
||||
|
||||
async function readLimitedText(response: FetchResponse) {
|
||||
|
||||
Reference in New Issue
Block a user