🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@taraflex/decode-html

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@taraflex/decode-html - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+1
-1
package.json
{
"name": "@taraflex/decode-html",
"version": "0.0.1",
"version": "0.0.2",
"description": "",

@@ -5,0 +5,0 @@ "license": "ISC",

import { decode } from 'iconv-lite';
import lastMatch from 'last-match';
const CHARSET_RE = /charset\s*=\s*"*\s*([-a-z0-9]+)/i;
export default (buf: Buffer, mime?: string) => {
let charset = mime ? lastMatch(mime, CHARSET_RE) : null;
let uBuf: string = null;
if (!charset) {
uBuf = buf.toString('utf-8');
charset = lastMatch(uBuf, CHARSET_RE) || 'utf-8';
}
charset = charset.toLowerCase();
return charset === 'utf-8' && uBuf ? uBuf : decode(buf, charset);
}