mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
Fix optimization path for unicodeSlice
This commit is contained in:
@@ -31,6 +31,7 @@ describe('unicodeSlice()', () => {
|
||||
test('multi-byte char', 'x€x', 1, 4, '€', 3);
|
||||
test('multi-byte char slice before end', '€', 1, 3, '', 0);
|
||||
test('multi-byte char slice after start', '€', 2, 4, '', 0);
|
||||
test('ignores utf-16 length', '€123', 0, 4, '€1', 4);
|
||||
|
||||
test('emoji', 'x👩👩👧👦x', 1, 26, '👩👩👧👦', 25);
|
||||
test('emoji slice before end', 'x👩👩👧👦x', 1, 25, '', 0);
|
||||
|
||||
@@ -21,7 +21,7 @@ export function unicodeSlice(
|
||||
end: number
|
||||
): string {
|
||||
// Optimization: whole string fits into the range, return as is
|
||||
if (begin === 0 && end >= input.length) {
|
||||
if (begin === 0 && end >= Buffer.byteLength(input)) {
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user