Skip to content

Commit

Permalink
Fix link metadata endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Oct 29, 2024
1 parent da9e2ce commit 4da0ff8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { fetchBuilder, FileSystemCache } from "node-fetch-cache";
import { useAgent } from "request-filtering-agent";

import cache from "./cache.mjs";
import log from "./logger.mjs";

const fetch = fetchBuilder.withCache(
new FileSystemCache({
Expand Down Expand Up @@ -66,7 +67,7 @@ export const metadata = async (url) => {
signal,
});

const html = await response.text();
html = await response.text();
const parsed = await ogs({ html });
result = parsed.result;

Expand Down Expand Up @@ -94,7 +95,11 @@ export const metadata = async (url) => {
// NOTE: Hey's and Rekt News's canonical link implementation is wrong and
// always links back to the root
if (domain !== "hey.xyz" || domain !== "rekt.news") {
canonicalLink = await extractCanonicalLink(html);
try {
canonicalLink = await extractCanonicalLink(html);
} catch (err) {
log(`Failed to extract canonical link ${err.stack}`);
}
}

let output = {};
Expand Down

0 comments on commit 4da0ff8

Please sign in to comment.