Comparing version 2.0.0 to 2.0.1
33
index.js
@@ -6,2 +6,3 @@ "use strict"; | ||
const mappingTable = require("./lib/mappingTable.json"); | ||
const { STATUS_MAPPING } = require("./lib/statusMapping.js"); | ||
@@ -20,9 +21,17 @@ function containsNonASCII(str) { | ||
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; | ||
@@ -45,12 +54,12 @@ } else { | ||
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") { | ||
@@ -62,3 +71,3 @@ processed += mapping; | ||
break; | ||
case "valid": | ||
case STATUS_MAPPING.valid: | ||
processed += ch; | ||
@@ -96,5 +105,5 @@ break; | ||
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; | ||
@@ -101,0 +110,0 @@ } |
{ | ||
"name": "tr46", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"description": "An implementation of the Unicode TR46 spec", | ||
"description": "An implementation of the Unicode UTS #46: Unicode IDNA Compatibility Processing", | ||
"main": "index.js", | ||
@@ -20,6 +20,8 @@ "files": [ | ||
}, | ||
"repository": "https://github.com/jsdom/tr46.js", | ||
"repository": "https://github.com/jsdom/tr46", | ||
"keywords": [ | ||
"unicode", | ||
"tr46", | ||
"uts46", | ||
"punycode", | ||
"url", | ||
@@ -39,4 +41,5 @@ "whatwg" | ||
"mocha": "^6.2.2", | ||
"node-fetch": "^2.6.0", | ||
"pump": "^3.0.0", | ||
"regenerate": "^1.4.0", | ||
"request": "^2.88.0", | ||
"unicode-12.1.0": "^0.8.0" | ||
@@ -43,0 +46,0 @@ }, |
@@ -1,4 +0,4 @@ | ||
# tr46.js | ||
# tr46 | ||
> An implementation of [Unicode Technical Standard #46: Unicode IDNA Compatibility Processing](https://unicode.org/reports/tr46/). | ||
An JavaScript implementation of [Unicode Technical Standard #46: Unicode IDNA Compatibility Processing](https://unicode.org/reports/tr46/). | ||
@@ -5,0 +5,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
524
0
207369
6