Skip to content

Commit

Permalink
Handle Surrogate Pairs in truncate() (mastodon#25148)
Browse files Browse the repository at this point in the history
  • Loading branch information
eai04191 committed May 29, 2023
1 parent 11b8336 commit 64b960b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/javascript/mastodon/features/status/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 64b960b

Please sign in to comment.