Skip to content

Commit 4e8d46f

Browse files
committed
refactor: handle neg num in truncate
1 parent 4275db0 commit 4e8d46f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

app/utils/string.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export function truncate(s: string, n: number): string {
2+
if (n <= 0) return ''
23
return s.length > n ? s.slice(0, n - 1) + '…' : s
34
}

0 commit comments

Comments
 (0)