1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-03 04:10:04 +02:00

update packages to latest version

This commit is contained in:
s2
2022-08-20 18:51:33 +02:00
parent 09663a35a5
commit 806ebf9a57
4513 changed files with 366205 additions and 92512 deletions

View File

@@ -1,8 +1,11 @@
{
"866": "IBM866",
"unicode-1-1-utf-8": "UTF-8",
"unicode11utf8": "UTF-8",
"unicode20utf8": "UTF-8",
"utf-8": "UTF-8",
"utf8": "UTF-8",
"x-unicode20utf8": "UTF-8",
"cp866": "IBM866",
"csibm866": "IBM866",
"ibm866": "IBM866",
@@ -201,7 +204,13 @@
"ksc5601": "EUC-KR",
"ksc_5601": "EUC-KR",
"windows-949": "EUC-KR",
"unicodefffe": "UTF-16BE",
"utf-16be": "UTF-16BE",
"csunicode": "UTF-16LE",
"iso-10646-ucs-2": "UTF-16LE",
"ucs-2": "UTF-16LE",
"unicode": "UTF-16LE",
"unicodefeff": "UTF-16LE",
"utf-16": "UTF-16LE",
"utf-16le": "UTF-16LE"
}

View File

@@ -13,29 +13,29 @@ exports.labelToName = label => {
};
// https://encoding.spec.whatwg.org/#decode
exports.decode = (buffer, fallbackEncodingName) => {
exports.decode = (uint8Array, fallbackEncodingName) => {
let encoding = fallbackEncodingName;
if (!exports.isSupported(encoding)) {
throw new RangeError(`"${encoding}" is not a supported encoding name`);
}
const bomEncoding = exports.getBOMEncoding(buffer);
const bomEncoding = exports.getBOMEncoding(uint8Array);
if (bomEncoding !== null) {
encoding = bomEncoding;
}
// iconv-lite will strip BOMs for us, so no need to do the stuff the spec does
return iconvLite.decode(buffer, encoding);
return iconvLite.decode(uint8Array, encoding);
};
// https://github.com/whatwg/html/issues/1910#issuecomment-254017369
exports.getBOMEncoding = buffer => {
if (buffer[0] === 0xFE && buffer[1] === 0xFF) {
exports.getBOMEncoding = uint8Array => {
if (uint8Array[0] === 0xFE && uint8Array[1] === 0xFF) {
return "UTF-16BE";
} else if (buffer[0] === 0xFF && buffer[1] === 0xFE) {
} else if (uint8Array[0] === 0xFF && uint8Array[1] === 0xFE) {
return "UTF-16LE";
} else if (buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
} else if (uint8Array[0] === 0xEF && uint8Array[1] === 0xBB && uint8Array[2] === 0xBF) {
return "UTF-8";
}