From 64b960b6b33086a20b3db8f442c7f2fd2f9b855b Mon Sep 17 00:00:00 2001 From: "y.takahashi" Date: Mon, 29 May 2023 18:55:16 +0900 Subject: [PATCH] Handle Surrogate Pairs in truncate() (#25148) --- app/javascript/mastodon/features/status/index.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/features/status/index.jsx b/app/javascript/mastodon/features/status/index.jsx index 0ed94d34c..195c6b523 100644 --- a/app/javascript/mastodon/features/status/index.jsx +++ b/app/javascript/mastodon/features/status/index.jsx @@ -166,8 +166,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; }