[Glitch] Handle Surrogate Pairs in truncate()
Port 5c744a5d7d
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
lolsob-rspec
parent
bda5be1406
commit
e7cb0dc83b
|
@ -161,8 +161,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