Mercurial > prosody-hg
annotate util/jid.lua @ 38:3fdfd6e0cb4e
SASL!
(but before you get too excited, no resource binding yet. And yes, there are still plenty of rough edges to the code...)
((eg. must move <stream:features> out of xmlhandlers.lua o_O ))
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 02 Oct 2008 01:08:58 +0100 |
| parents | b847875801e5 |
| children | cfbd3b849f9e |
| rev | line source |
|---|---|
| 0 | 1 |
| 2 local match = string.match; | |
| 3 | |
| 4 module "jid" | |
| 5 | |
| 6 function split(jid) | |
|
29
b847875801e5
jid.split(): Return nil when passed nil
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
7 if not jid then return nil; end |
|
27
859b316e2fb0
Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
8 local node = match(jid, "^([^@]+)@"); |
|
859b316e2fb0
Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
9 local server = (node and match(jid, ".-@([^@/]+)")) or match(jid, "^([^@/]+)"); |
|
859b316e2fb0
Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
10 local resource = match(jid, "/(.+)$"); |
|
859b316e2fb0
Fixing jid.split() for all JIDs
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
11 return node, server, resource; |
| 0 | 12 end |
