Skip to content

Commit

Permalink
Merge pull request #232 from jshemas/jul-16
Browse files Browse the repository at this point in the history
Updating dependencies to fix npm vulnerabilities
  • Loading branch information
jshemas authored Jul 17, 2024
2 parents 52e3069 + 38672c8 commit 854d34b
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 226 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 6.6.3

- Fix issue with the `charset` fallback. Replace Buffer.from with Uint8Array since body is always html
- Updating dependencies to fix npm vulnerabilities

## 6.6.2

- Fixed issue with `package.json` `exports` was not working in `CommonJs` projects.
Expand Down
4 changes: 3 additions & 1 deletion lib/fallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export function fallback(ogObject: OgObjectInteral, options: OpenGraphScraperOpt
if (charsetRegExExec?.[1]) ogObject.charset = charsetRegExExec[1] || 'utf-8';
}
} else if (body) {
ogObject.charset = chardet.detect(Buffer.from(body)) ?? '';
const encoder = new TextEncoder();
const uint8Array = encoder.encode(body);
ogObject.charset = chardet.detect(uint8Array) ?? '';
}

return ogObject;
Expand Down
Loading

0 comments on commit 854d34b

Please sign in to comment.