mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
fix: update axios request to include base URL in getMeta function and refactor decodeHtml function in posts
This commit is contained in:
@@ -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(/"/g, '"')
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/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(/"/g, '"')
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/g, "&");
|
||||
|
||||
return decoded;
|
||||
}
|
||||
const res = await axios.get(url, {
|
||||
headers: {
|
||||
referer: baseUrl,
|
||||
|
||||
Reference in New Issue
Block a user