~cytrogen/masto-fe

64b960b6b33086a20b3db8f442c7f2fd2f9b855b — y.takahashi 2 years ago 11b8336
Handle Surrogate Pairs in truncate() (#25148)

1 files changed, 3 insertions(+), 2 deletions(-)

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