diff --git a/lib/irc.js b/lib/irc.js index bd5dc38e..2cc59b59 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -960,6 +960,7 @@ Client.prototype.action = function(channel, text) { }; Client.prototype._splitLongLines = function(words, maxLength, destination) { + maxLength = maxLength || 450; // If maxLength hasn't been initialized yet, prefer an arbitrarily low line length over crashing. if (words.length == 0) { return destination; } diff --git a/test/data/fixtures.json b/test/data/fixtures.json index 00833469..a15cce92 100644 --- a/test/data/fixtures.json +++ b/test/data/fixtures.json @@ -177,5 +177,11 @@ "maxLength": 5, "result": ["abc", "abcde", "f abc", "abcd", "abc"] } - ] + ], + "_splitLongLines_no_max": [ + { + "input": "abcdefghijklmnopqrstuvwxyz", + "result": ["abcdefghijklmnopqrstuvwxyz"] + } + ] } diff --git a/test/test-irc.js b/test/test-irc.js index c9b27e9e..6a315a54 100644 --- a/test/test-irc.js +++ b/test/test-irc.js @@ -84,3 +84,23 @@ test ('splitting of long lines', function(t) { }); mock.close(); }); + +test ('splitting of long lines with no maxLength defined.', function(t) { + var port = 6667; + var mock = testHelpers.MockIrcd(port, 'utf-8', false); + var client = new irc.Client('localhost', 'testbot', { + secure: false, + selfSigned: true, + port: port, + retryCount: 0, + debug: true + }); + + var group = testHelpers.getFixtures('_splitLongLines_no_max'); + console.log(group.length); + t.plan(group.length); + group.forEach(function(item) { + t.deepEqual(client._splitLongLines(item.input, null, []), item.result); + }); + mock.close(); +}); \ No newline at end of file