mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 16:43:41 +01:00
Handle Surrogate Pairs in truncate() (#25148)
This commit is contained in:
parent
11b8336418
commit
64b960b6b3
1 changed files with 3 additions and 2 deletions
|
@ -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…
Reference in a new issue