From 4993b6e80012dd92259771b5e2cd52e00b1d35c8 Mon Sep 17 00:00:00 2001 From: "y.takahashi" Date: Mon, 29 May 2023 18:55:16 +0900 Subject: [PATCH] [Glitch] Handle Surrogate Pairs in truncate() Port 64b960b6b33086a20b3db8f442c7f2fd2f9b855b to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/features/status/index.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 0c7a016644..d961a0d980 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -161,8 +161,9 @@ const makeMapStateToProps = () => { }; const truncate = (str, num) => { - if (str.length > num) { - return str.slice(0, num) + '…'; + const arr = Array.from(str); + if (arr.length > num) { + return arr.slice(0, num).join('') + '…'; } else { return str; }