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

update modules

This commit is contained in:
s2
2020-07-20 16:16:07 +02:00
parent 783511ce12
commit 2b23424b86
785 changed files with 91905 additions and 56057 deletions

38
node_modules/tr46/index.js generated vendored
View File

@@ -3,6 +3,7 @@
const punycode = require("punycode");
const regexes = require("./lib/regexes.js");
const mappingTable = require("./lib/mappingTable.json");
const { STATUS_MAPPING } = require("./lib/statusMapping.js");
function containsNonASCII(str) {
return /[^\x00-\x7F]/.test(str);
@@ -16,13 +17,21 @@ function findStatus(val, { useSTD3ASCIIRules }) {
const mid = Math.floor((start + end) / 2);
const target = mappingTable[mid];
if (target[0][0] <= val && target[0][1] >= val) {
if (target[1].startsWith("disallowed_STD3_")) {
const newStatus = useSTD3ASCIIRules ? "disallowed" : target[1].slice(16);
return [newStatus, ...target.slice(2)];
const min = Array.isArray(target[0]) ? target[0][0] : target[0];
const max = Array.isArray(target[0]) ? target[0][1] : target[0];
if (min <= val && max >= val) {
if (useSTD3ASCIIRules &&
(target[1] === STATUS_MAPPING.disallowed_STD3_valid || target[1] === STATUS_MAPPING.disallowed_STD3_mapped)) {
return [STATUS_MAPPING.disallowed, ...target.slice(2)];
} else if (target[1] === STATUS_MAPPING.disallowed_STD3_valid) {
return [STATUS_MAPPING.valid, ...target.slice(2)];
} else if (target[1] === STATUS_MAPPING.disallowed_STD3_mapped) {
return [STATUS_MAPPING.mapped, ...target.slice(2)];
}
return target.slice(1);
} else if (target[0][0] > val) {
} else if (min > val) {
end = mid - 1;
} else {
start = mid + 1;
@@ -40,23 +49,23 @@ function mapChars(domainName, { useSTD3ASCIIRules, processingOption }) {
const [status, mapping] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });
switch (status) {
case "disallowed":
case STATUS_MAPPING.disallowed:
hasError = true;
processed += ch;
break;
case "ignored":
case STATUS_MAPPING.ignored:
break;
case "mapped":
case STATUS_MAPPING.mapped:
processed += mapping;
break;
case "deviation":
case STATUS_MAPPING.deviation:
if (processingOption === "transitional") {
processed += mapping;
} else {
processed += ch;
}
break;
case "valid":
case STATUS_MAPPING.valid:
processed += ch;
break;
}
@@ -89,9 +98,9 @@ function validateLabel(label, { checkHyphens, checkBidi, checkJoiners, processin
for (const ch of codePoints) {
const [status] = findStatus(ch.codePointAt(0), { useSTD3ASCIIRules });
if ((processingOption === "transitional" && status !== "valid") ||
if ((processingOption === "transitional" && status !== STATUS_MAPPING.valid) ||
(processingOption === "nontransitional" &&
status !== "valid" && status !== "deviation")) {
status !== STATUS_MAPPING.valid && status !== STATUS_MAPPING.deviation)) {
return false;
}
}
@@ -265,10 +274,11 @@ function toUnicode(domainName, {
checkHyphens = false,
checkBidi = false,
checkJoiners = false,
useSTD3ASCIIRules = false
useSTD3ASCIIRules = false,
processingOption = "nontransitional"
} = {}) {
const result = processing(domainName, {
processingOption: "nontransitional",
processingOption,
checkHyphens,
checkBidi,
checkJoiners,