Skip to content

Commit 4669d34

Browse files
committed
truncate_words actually truncates after the correct amount of words now
1 parent 0c6ad95 commit 4669d34

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

cloudbot/util/formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def truncate_words(content, length=10, suffix='...'):
147147
out = None
148148
x = 0
149149
for i in msg:
150-
if x <= length:
150+
if x < length:
151151
if out:
152152
out = out + " " + msg[x]
153153
else:

cloudbot/util/test/test_formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
test_truncate_words_input = "I am the example string for a unit test"
2929
test_truncate_words_length_a = 5
3030
test_truncate_words_length_b = 100
31-
test_truncate_words_result_a = "I am the example string for..."
31+
test_truncate_words_result_a = "I am the example string..."
3232
test_truncate_words_result_b = "I am the example string for a unit test"
3333

3434
test_strip_html_input = "<strong>Cats &amp; Dogs: &#181;</strong>"

0 commit comments

Comments
 (0)