diff options
author | Joe Crayne <joe@jerkface.net> | 2018-11-06 01:20:32 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-11-06 04:34:03 -0500 |
commit | 461c8f70d81209d6a4da6b9ab76b6487c13df07d (patch) | |
tree | c5419531a6942f8e643a5fda333df6f049aca3dd /Presence/Util.hs | |
parent | fb4ad2167102046125c822841dabf3edba32ed85 (diff) |
splitJID: resource may include @ symbol.
Diffstat (limited to 'Presence/Util.hs')
-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 | ||