From 6580ea9912cc296680414e775244a50534667a10 Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 15 May 2023 21:27:15 +0200 Subject: Split JID logic into xmpp/jid.go --- xmpp/jid.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 xmpp/jid.go (limited to 'xmpp/jid.go') diff --git a/xmpp/jid.go b/xmpp/jid.go new file mode 100644 index 0000000..f3a5d49 --- /dev/null +++ b/xmpp/jid.go @@ -0,0 +1,23 @@ +package xmpp + +// domainpart extracts the domain name from a JID / XMPP address. See +// https://datatracker.ietf.org/doc/html/rfc7622#section-3.2 for details. +func domainpart(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+1:] + break + } + } + + return string(list) +} -- cgit v1.2.3-70-g09d2