Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit ed55b3c

Browse files
committed
Handle inbox thread title truncation when there are no spaces in the thread title
1 parent 0f46623 commit ed55b3c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

shared/truncate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function truncate(str /*: string */, length /*: number */) {
1515
return str;
1616
}
1717
var subString = str.substr(0, length);
18+
19+
// if the title doesn't have any spaces in it, just break at the normal length
20+
if (subString.indexOf(' ') < 0) return subString + '…';
21+
22+
// if the title has a space character, attempt to break between words
1823
return (
1924
subString.substr(0, subString.lastIndexOf(' ')).replace(/\n/, ' ') + '…'
2025
);

0 commit comments

Comments
 (0)