Skip to content

Commit

Permalink
fix: text slicer
Browse files Browse the repository at this point in the history
  • Loading branch information
okradze committed Nov 29, 2023
1 parent c667726 commit 6fcd48c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/ui/src/utils/textSlicer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const textSlicer = (text: string, maxLength: number) => {
let shortText = text?.slice(0, maxLength) || ''
export const textSlicer = (text: string | number | undefined, maxLength: number) => {
text = String(text)
if (!text) return { shortText: '' }

let shortText = text?.slice(0, maxLength) || ''

// Check if the last character is a space and remove it if it is
if (shortText.charAt(shortText.length - 1) === ' ') {
Expand Down

0 comments on commit 6fcd48c

Please sign in to comment.