Skip to content

Commit

Permalink
fix: unescape in get frame metadata (#478)
Browse files Browse the repository at this point in the history
* fix: unescape escaped symbols in `getFrameMetadata`

* chore: changesets
  • Loading branch information
dalechyn authored Aug 29, 2024
1 parent 850e8f5 commit 0f482cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/light-needles-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Fixed an issue where `getFrameMetadata` would return escaped symbols.
12 changes: 11 additions & 1 deletion src/utils/getFrameMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ export async function getFrameMetadata(url: string): Promise<FrameMetadata> {
try {
const text = await fetch(url).then((r) => r.text())

const dom = parseFromString(text.replace(/<!doctype html>/i, ''))
const dom = parseFromString(
text
.replace(/<!doctype html>/i, '')
// @TODO: consider using `lodash.unescape`
.replaceAll(/&amp;/gm, '&')
.replaceAll(/&lt;/gm, '<')
.replaceAll(/&gt;/gm, '>')
.replaceAll(/&quot;/gm, '"')
.replaceAll(/&#39;/gm, "'")
.replaceAll(/&#96;/gm, '`'),
)
const nodes = dom.getElementsByTagName('meta')

const metaTags: FrameMetadata = []
Expand Down

0 comments on commit 0f482cd

Please sign in to comment.