Handle Surrogate Pairs in truncate() (#25148)

lolsob-rspec
y.takahashi 2023-05-29 18:55:16 +09:00 committed by GitHub
parent dd0d755824
commit 5c744a5d7d
1 changed files with 3 additions and 2 deletions

View File

@ -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;
}