fix: update axios request to include base URL in getMeta function and refactor decodeHtml function in posts

This commit is contained in:
himanshu8443
2025-06-18 20:22:26 +05:30
parent 7b8bd2be97
commit 5051ccb916
2 changed files with 25 additions and 24 deletions

View File

@@ -49,29 +49,29 @@ async function posts({
axios: ProviderContext["axios"];
cheerio: ProviderContext["cheerio"];
}): Promise<Post[]> {
function decodeHtml(encodedArray: string[]): string {
// Join array elements into a single string
const joined = encodedArray.join("");
// Replace escaped quotes
const unescaped = joined.replace(/\\"/g, '"').replace(/\\'/g, "'");
// Remove remaining escape characters
const cleaned = unescaped
.replace(/\\n/g, "\n")
.replace(/\\t/g, "\t")
.replace(/\\r/g, "\r");
// Convert literal string representations back to characters
const decoded = cleaned
.replace(/&quot;/g, '"')
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&amp;/g, "&");
return decoded;
}
try {
function decodeHtml(encodedArray: string[]): string {
// Join array elements into a single string
const joined = encodedArray.join("");
// Replace escaped quotes
const unescaped = joined.replace(/\\"/g, '"').replace(/\\'/g, "'");
// Remove remaining escape characters
const cleaned = unescaped
.replace(/\\n/g, "\n")
.replace(/\\t/g, "\t")
.replace(/\\r/g, "\r");
// Convert literal string representations back to characters
const decoded = cleaned
.replace(/&quot;/g, '"')
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&amp;/g, "&");
return decoded;
}
const res = await axios.get(url, {
headers: {
referer: baseUrl,