Handle Surrogate Pairs in truncate() (#25148)
This commit is contained in:
parent
11b8336418
commit
64b960b6b3
|
@ -166,8 +166,9 @@ const makeMapStateToProps = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const truncate = (str, num) => {
|
const truncate = (str, num) => {
|
||||||
if (str.length > num) {
|
const arr = Array.from(str);
|
||||||
return str.slice(0, num) + '…';
|
if (arr.length > num) {
|
||||||
|
return arr.slice(0, num).join('') + '…';
|
||||||
} else {
|
} else {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue