Gathering detailed insights and metrics for html-encoding-sniffer-xs
Gathering detailed insights and metrics for html-encoding-sniffer-xs
Gathering detailed insights and metrics for html-encoding-sniffer-xs
Gathering detailed insights and metrics for html-encoding-sniffer-xs
npm install html-encoding-sniffer-xs
Typescript
Module System
Min. Node Version
Node Version
NPM Version
70.6
Supply Chain
76.6
Quality
74.7
Maintenance
100
Vulnerability
100
License
JavaScript (84.55%)
HTML (15.45%)
Total Downloads
22,074
Last Day
3
Last Week
10
Last Month
39
Last Year
757
MIT License
14 Commits
1 Branches
1 Contributors
Updated on Mar 26, 2020
Minified
Minified + Gzipped
Latest Version
1.0.0
Package Id
html-encoding-sniffer-xs@1.0.0
Unpacked Size
11.30 kB
Size
3.77 kB
File Count
4
NPM Version
6.14.2
Node Version
12.16.1
Cumulative downloads
Total Downloads
Last Day
0%
3
Compared to previous day
Last Week
-47.4%
10
Compared to previous week
Last Month
-15.2%
39
Compared to previous month
Last Year
-55.8%
757
Compared to previous year
1
This package implements the HTML Standard's encoding sniffing algorithm in all its glory. The most interesting part of this is how it pre-scans the first 1024 bytes in order to search for certain <meta charset>
-related patterns.
1const htmlEncodingSniffer = require("html-encoding-sniffer"); 2const fs = require("fs"); 3 4const htmlBuffer = fs.readFileSync("./html-page.html"); 5const sniffedEncoding = htmlEncodingSniffer(htmlBuffer);
The returned value will be a canonical encoding name (not a label). You might then combine this with the whatwg-encoding package to decode the result:
1const whatwgEncoding = require("whatwg-encoding"); 2const htmlString = whatwgEncoding.decode(htmlBuffer, sniffedEncoding);
You can pass two potential options to htmlEncodingSniffer
:
1const sniffedEncoding = htmlEncodingSniffer(htmlBuffer, {
2 transportLayerEncodingLabel,
3 defaultEncoding
4});
These represent two possible inputs into the encoding sniffing algorithm:
transportLayerEncodingLabel
is an encoding label that is obtained from the "transport layer" (probably a HTTP Content-Type
header), which overrides everything but a BOM.defaultEncoding
is the ultimate fallback encoding used if no valid encoding is supplied by the transport layer, and no encoding is sniffed from the bytes. It defaults to "windows-1252"
, as recommended by the algorithm's table of suggested defaults for "All other locales" (including the en
locale).This package was originally based on the excellent work of @nicolashenry, in jsdom. It has since been pulled out into this separate package.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-05-19
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More