From 0f482cdb3d93500dbf4888c6030462bb93a8d0cb Mon Sep 17 00:00:00 2001 From: Vladyslav Dalechyn Date: Thu, 29 Aug 2024 18:01:03 +0300 Subject: [PATCH] fix: unescape in get frame metadata (#478) * fix: unescape escaped symbols in `getFrameMetadata` * chore: changesets --- .changeset/light-needles-tap.md | 5 +++++ src/utils/getFrameMetadata.ts | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changeset/light-needles-tap.md diff --git a/.changeset/light-needles-tap.md b/.changeset/light-needles-tap.md new file mode 100644 index 00000000..2725c364 --- /dev/null +++ b/.changeset/light-needles-tap.md @@ -0,0 +1,5 @@ +--- +"frog": patch +--- + +Fixed an issue where `getFrameMetadata` would return escaped symbols. diff --git a/src/utils/getFrameMetadata.ts b/src/utils/getFrameMetadata.ts index c3149125..b2595ae9 100644 --- a/src/utils/getFrameMetadata.ts +++ b/src/utils/getFrameMetadata.ts @@ -36,7 +36,17 @@ export async function getFrameMetadata(url: string): Promise { try { const text = await fetch(url).then((r) => r.text()) - const dom = parseFromString(text.replace(//i, '')) + const dom = parseFromString( + text + .replace(//i, '') + // @TODO: consider using `lodash.unescape` + .replaceAll(/&/gm, '&') + .replaceAll(/</gm, '<') + .replaceAll(/>/gm, '>') + .replaceAll(/"/gm, '"') + .replaceAll(/'/gm, "'") + .replaceAll(/`/gm, '`'), + ) const nodes = dom.getElementsByTagName('meta') const metaTags: FrameMetadata = []