diff options
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/Util.hs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Presence/Util.hs b/Presence/Util.hs index a6e5b35f..ef98d415 100644 --- a/Presence/Util.hs +++ b/Presence/Util.hs | |||
@@ -23,17 +23,12 @@ unsplitJID (n,h,r) = username <> h <> resource | |||
23 | 23 | ||
24 | splitJID :: Text -> (Maybe UserName,Text,Maybe ResourceName) | 24 | splitJID :: Text -> (Maybe UserName,Text,Maybe ResourceName) |
25 | splitJID bjid = | 25 | splitJID bjid = |
26 | let xs = splitAll '@' bjid | 26 | let (uATh,slashrsc) = Text.break (=='/') bjid |
27 | ys = splitAll '/' (last xs) | 27 | rsrc = if Text.null slashrsc then Nothing |
28 | splitAll c bjid = take 1 xs0 ++ map (Text.drop 1) (drop 1 xs0) | 28 | else Just $ Text.drop 1 slashrsc |
29 | where xs0 = Text.groupBy (\x y-> y/=c) bjid | 29 | (u,atserver) = Text.break (=='@') uATh |
30 | server = head ys | 30 | (name,server) = if Text.null atserver then (Nothing,u) |
31 | name = case xs of | 31 | else (Just u,Text.drop 1 atserver) |
32 | (n:s:_) -> Just n | ||
33 | _ -> Nothing | ||
34 | rsrc = case ys of | ||
35 | (s:_:_) -> Just $ last ys | ||
36 | _ -> Nothing | ||
37 | in (name,server,rsrc) | 32 | in (name,server,rsrc) |
38 | 33 | ||
39 | 34 | ||