gracefully handle spaces in non-last params (split them)

This commit is contained in:
jesopo 2020-03-11 23:05:11 +00:00
parent e41a58842b
commit a82105e09f
2 changed files with 11 additions and 1 deletions

View File

@ -77,7 +77,12 @@ class Line(object):
params = self.params.copy()
if self.params:
last = params.pop(-1)
outs.extend(params)
for param in params:
if " " in param:
outs.extend(param.split(" "))
else:
outs.append(param)
if " " in last:
last = f":{last}"
outs.append(last)

View File

@ -40,3 +40,8 @@ class FormatTestTrailing(unittest.TestCase):
def test_no_space(self):
line = irctokens.format("PRIVMSG", ["#channel", "helloworld"])
self.assertEqual(line, "PRIVMSG #channel helloworld")
class FormatTestSpacedArg(unittest.TestCase):
def test(self):
line = irctokens.format("USER", ["user", "0 *", "real name"])
self.assertEqual(line, "USER user 0 * :real name")