Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

charset

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

charset - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

5

History.md
1.0.0 / 2014-09-17
==================
* add peek size, default is 512. fixed #4
0.1.0 / 2014-07-05

@@ -3,0 +8,0 @@ ==================

13

lib/charset.js

@@ -20,2 +20,4 @@ /*!

module.exports = charset;
/**

@@ -31,3 +33,4 @@ * guest data charset from req.headers, xml, html content-type meta tag

* @param {Object} obj `Content-Type` String, or `res.headers`, or `res` Object
* @param {Buffer} data
* @param {Buffer} [data] content buffer
* @param {Number} [peekSize] max content peek size, default is 512
* @return {String} charset, lower case, e.g.: utf8, gbk, gb2312, ....

@@ -37,7 +40,9 @@ * If can\'t guest, return null

*/
module.exports = function charset(obj, data) {
function charset(obj, data, peekSize) {
var matchs = null;
var end = 0;
if (data) {
end = data.length > 512 ? 512 : data.length;
peekSize = peekSize || 512;
// https://github.com/node-modules/charset/issues/4
end = data.length > peekSize ? peekSize : data.length;
}

@@ -72,2 +77,2 @@ // charset('text/html;charset=gbk')

return cs;
};
}
{
"name": "charset",
"version": "0.1.0",
"version": "1.0.0",
"description": "Get the content charset from header and html content-type.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc