mirror of https://github.com/jesopo/irctokens
gracefully handle spaces in non-last params (split them)
This commit is contained in:
parent
e41a58842b
commit
a82105e09f
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue