Handle Surrogate Pairs in truncate() (#25148)

local
y.takahashi 12 months ago committed by GitHub
parent 11b8336418
commit 64b960b6b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      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;
}

Loading…
Cancel
Save