diff --git a/src/index.ts b/src/index.ts index dd5668b..f6e3fcc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ import type {TruncationOptions, WidthOptions, Result} from './types'; /* HELPERS */ const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y; -const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y; +const CONTROL_RE = /[\x00-\x08\x0B-\x1F\x7F-\x9F]{1,1000}/y; const TAB_RE = /\t{1,1000}/y; const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu; const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y; diff --git a/test/index.js b/test/index.js index a62c169..0a6be6c 100644 --- a/test/index.js +++ b/test/index.js @@ -62,6 +62,8 @@ describe ( 'Fast String Width', () => { t.is ( getWidth ( '\u{845B}\u{E0100}' ), 2 ); t.is ( getWidth ( 'ปฏัก' ), 3 ); t.is ( getWidth ( '_\u0E34' ), 1 ); + t.is ( getWidth ( '\n' ), 1 ); + t.is ( getWidth ( '\x20' ), 1 ); });