@oxyhq/core 10.1.3 → 10.1.4
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.
|
@@ -42,28 +42,6 @@
|
|
|
42
42
|
* the display-name character policy). These functions do exactly one thing:
|
|
43
43
|
* normalize whitespace and Unicode form.
|
|
44
44
|
*/
|
|
45
|
-
/**
|
|
46
|
-
* Characters that make a value ineligible for the zero-work fast path, and the
|
|
47
|
-
* whitespace shapes that a normalized INLINE value can never contain.
|
|
48
|
-
*
|
|
49
|
-
* A value that matches nothing here is, by construction, already normalized:
|
|
50
|
-
* it holds only printable ASCII (which is NFC-stable, so `normalize('NFC')`
|
|
51
|
-
* would be a no-op), its only whitespace is the plain space, it has no leading
|
|
52
|
-
* or trailing space, and no run of two spaces. Returning it untouched skips
|
|
53
|
-
* three string allocations — worth it because the common case in the feed
|
|
54
|
-
* hydration hot path is text that is already clean.
|
|
55
|
-
*
|
|
56
|
-
* Non-global (safe for repeated `.test()`; a global regex is stateful).
|
|
57
|
-
*/
|
|
58
|
-
const INLINE_NEEDS_NORMALIZATION = /[^\x20-\x7E]|^ | $| {2}/;
|
|
59
|
-
/**
|
|
60
|
-
* Same idea as {@link INLINE_NEEDS_NORMALIZATION}, for MULTILINE values: `\n`
|
|
61
|
-
* joins the printable-ASCII fast-path alphabet, and the additional shapes a
|
|
62
|
-
* normalized body can never contain are a space adjacent to a line break — on
|
|
63
|
-
* either side, since every line is trimmed — and a run of three line breaks
|
|
64
|
-
* (more than one blank line).
|
|
65
|
-
*/
|
|
66
|
-
const MULTILINE_NEEDS_NORMALIZATION = /[^\x20-\x7E\n]|^[ \n]|[ \n]$| {2}| \n|\n |\n{3}/;
|
|
67
45
|
/** Any run of whitespace, including tabs, line breaks and Unicode spaces. */
|
|
68
46
|
const ANY_WHITESPACE_RUN = /\s+/g;
|
|
69
47
|
/**
|
|
@@ -125,9 +103,6 @@ const EXCESS_BLANK_LINES = /\n{3,}/g;
|
|
|
125
103
|
* Idempotent: `f(f(x)) === f(x)`.
|
|
126
104
|
*/
|
|
127
105
|
export function normalizeInlineText(value) {
|
|
128
|
-
if (!INLINE_NEEDS_NORMALIZATION.test(value)) {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
106
|
return value.normalize('NFC').replace(ANY_WHITESPACE_RUN, ' ').trim();
|
|
132
107
|
}
|
|
133
108
|
/**
|
|
@@ -163,9 +138,6 @@ export function normalizeInlineText(value) {
|
|
|
163
138
|
* Idempotent: `f(f(x)) === f(x)`.
|
|
164
139
|
*/
|
|
165
140
|
export function normalizeMultilineText(value) {
|
|
166
|
-
if (!MULTILINE_NEEDS_NORMALIZATION.test(value)) {
|
|
167
|
-
return value;
|
|
168
|
-
}
|
|
169
141
|
return value
|
|
170
142
|
.normalize('NFC')
|
|
171
143
|
.replace(LINE_BREAK_FORMS, '\n')
|