typebox 1.3.18 → 1.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,14 +14,16 @@ function IsLabel(value) {
|
|
|
14
14
|
// ------------------------------------------------------------------
|
|
15
15
|
// NormalizeHostname
|
|
16
16
|
//
|
|
17
|
-
// Normalizes a hostname for label validation.
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
17
|
+
// Normalizes a hostname for label validation. Maps fullwidth
|
|
18
|
+
// codepoints to their ASCII equivalent (e.g. 'a' U+FF41 maps to
|
|
19
|
+
// 'a'), then normalizes for NFC such that equivalent codepoint
|
|
20
|
+
// sequences can be uniformly compared. It also removes codepoints
|
|
21
|
+
// that IDNA mapping ignores, and converts full stop variants to
|
|
22
|
+
// ASCII '.' so the hostname can be split into labels.
|
|
22
23
|
// ------------------------------------------------------------------
|
|
23
24
|
function NormalizeHostname(value) {
|
|
24
25
|
return value
|
|
26
|
+
.replace(/[\uff01-\uff5e]/g, (char) => String.fromCharCode(char.charCodeAt(0) - 0xfee0)) // RE_FULLWIDTH_MAPPING
|
|
25
27
|
.normalize('NFC')
|
|
26
28
|
.replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, '') // RE_IGNORED_MAPPING
|
|
27
29
|
.replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.'); // RE_FULL_STOP_MAPPING
|