Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1x 1x 326x | const INVISIBLE_UNICODE_REGEX =
// eslint-disable-next-line no-misleading-character-class
/[\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2028\u2029\u2060-\u2064\u2066-\u2069\u3164\uFEFF\uFFA0\uFFF9-\uFFFB]|\uDB40[\uDC01-\uDCFF]/g;
/**
* Strip invisible Unicode characters from a string.
* This removes zero-width characters, bidirectional marks, Unicode Tags (U+E0001-U+E00FF),
* interlinear annotation anchors, Mongolian free variation selectors,
* and other invisible formatting characters that can be used to hide content in links.
*
* @remarks This function strips ZWJ (U+200D) which may affect emoji sequences.
* It should only be applied to href attributes, not to visible text content.
* @param value The string to strip invisible characters from
* @returns The string with invisible characters removed
*/
export function stripInvisibleUnicode(value: string): string {
return value.replace(INVISIBLE_UNICODE_REGEX, '');
}
|