~cytrogen/masto-fe

4993b6e80012dd92259771b5e2cd52e00b1d35c8 — y.takahashi 2 years ago c22fc2f
[Glitch] Handle Surrogate Pairs in truncate()

Port 64b960b6b33086a20b3db8f442c7f2fd2f9b855b to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
1 files changed, 3 insertions(+), 2 deletions(-)

M app/javascript/flavours/glitch/features/status/index.jsx
M app/javascript/flavours/glitch/features/status/index.jsx => app/javascript/flavours/glitch/features/status/index.jsx +3 -2
@@ 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;
  }