From c46f1b0f2852f5bf9129d3aebe963263e46aecac Mon Sep 17 00:00:00 2001 From: Huda Joad Date: Sat, 25 Nov 2023 01:01:18 +0300 Subject: [PATCH] edited comments --- netlify/functions/handleMetadata.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/netlify/functions/handleMetadata.js b/netlify/functions/handleMetadata.js index e6c804f..7df26da 100644 --- a/netlify/functions/handleMetadata.js +++ b/netlify/functions/handleMetadata.js @@ -1,7 +1,6 @@ const fetch = require('node-fetch'); // Import for webscraping in fetchContentFromURL() import { OpenAIApi, Configuration } from 'openai'; // const { Configuration, OpenAIApi } = require('openai'); -// import { he } from 'he'; // Function to fetch content from URL using a web scraping service async function fetchContentFromURL(url) { @@ -25,13 +24,7 @@ function simplifyContent(content) { simplifiedContent = simplifiedContent.replace(/.*?<\/style>/gms, ''); // Remove all remaining HTML tags, leaving the inner text simplifiedContent = simplifiedContent.replace(/<[^>]+>/g, ''); - // // Decode HTML entities - for a Node.js environment, consider using a library like 'he' - // simplifiedContent = simplifiedContent.replace(/&[a-z]+;/gi, match => { - // // This part is for browser environments, adjust for Node.js if necessary - // const span = document.createElement('span'); - // span.innerHTML = match; - // return span.textContent || span.innerText; - // }); + // Manually replace common HTML entities simplifiedContent = simplifiedContent .replace(/&/g, '&') .replace(/</g, '<')