mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-01-29 11:03:08 -05:00
[Glitch] Handle Surrogate Pairs in truncate()
Port 64b960b6b33086a20b3db8f442c7f2fd2f9b855b to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
c22fc2fa80
commit
4993b6e800
@ -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…
x
Reference in New Issue
Block a user