Skip to content

Commit

Permalink
fix(util): handling of unicode chars truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
atrifat committed Aug 8, 2024
1 parent 746752d commit 27d6e1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ export async function deleteFile(filePath) {
export const nMinutesAgo = (n) => Math.floor((Date.now() - n * 60 * 1000) / 1000);

export const truncateString = (text, n) => {
return (text.length > n) ? text.slice(0, n-1): text;
let chars = Array.from(String(text));
return (chars.length > n) ? chars.slice(0, n - 1).join('') : text;
}

0 comments on commit 27d6e1a

Please sign in to comment.