[Glitch] Handle Surrogate Pairs in truncate()
Port 64b960b6b3 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
			
			
This commit is contained in:
		@@ -161,8 +161,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;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user