Skip to content

Commit 5bbe29d

Browse files
committed
Don't truncate when it's exactly the max length
1 parent 26717a6 commit 5bbe29d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/raven.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,9 @@ function objectMerge(obj1, obj2) {
561561
}
562562

563563
function truncate(str, max) {
564+
var before = str.length;
564565
str = str.substr(0, max);
565-
if (str.length === max) {
566+
if (str.length !== before) {
566567
str += '…';
567568
}
568569
return str;

test/raven.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ describe('globals', function() {
204204
it('should work as advertised', function() {
205205
assert.equal(truncate('lolol', 3), 'lol…');
206206
assert.equal(truncate('lolol', 10), 'lolol');
207+
assert.equal(truncate('lol', 3), 'lol');
207208
});
208209
});
209210

0 commit comments

Comments
 (0)