From bfffca845be49cc2a113602cd994a2f430b95f58 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 25 May 2023 18:57:36 +0200 Subject: Add unit test for xmpp.username() and fix it The second unit test detected a bug - they are worth the effort! --- xmpp/jid.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'xmpp/jid.go') diff --git a/xmpp/jid.go b/xmpp/jid.go index 672e934..90c1509 100644 --- a/xmpp/jid.go +++ b/xmpp/jid.go @@ -25,19 +25,11 @@ func domainpart(jid string) string { func username(jid string) string { list := []rune(jid) - for i, v := range list { - if v == '/' { - list = list[:i] - break - } - } - for i, v := range list { if v == '@' { - list = list[:i] - break + return string(list[:i]) } } - return string(list) + return "" } -- cgit v1.2.3-70-g09d2