Skip to content

Commit

Permalink
enhance(functions): don't fail if canonicalUrl cannot be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Jul 25, 2024
1 parent 7b1e1f1 commit 2fb81d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions/grapher/[slug].ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export const onRequestGet: PagesFunction = async (context) => {
element: (element) => {
const canonicalUrl = element.getAttribute("content")
element.setAttribute("content", canonicalUrl + url.search)
origin = new URL(canonicalUrl).origin
try {
origin = new URL(canonicalUrl).origin
} catch (e) {
console.error("Error parsing canonical URL", e)
}
},
})
.on('meta[property="og:image"]', {
Expand Down

0 comments on commit 2fb81d3

Please sign in to comment.