diff options
author | Clombrong <cromblong@egregore.fun> | 2025-07-01 21:38:51 +0200 |
---|---|---|
committer | Clombrong <cromblong@egregore.fun> | 2025-07-26 21:55:50 +0200 |
commit | abc98ea631935be7d943098fb40a9811cfa45de3 (patch) | |
tree | 10142b0f1f7a32db1793194c33fb243492e96ad9 | |
parent | 2e2f475c5c631b61d061e7a308826214770fef47 (diff) |
fix(jid): calculate domain length right
-rw-r--r-- | lib/jid.ml | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -38,17 +38,17 @@ let of_string (s : string) : t = then Some (i, drop i jid |> string_of_uchars) else None) jid |> Option.fold ~none:(length jid, None) ~some:(fun (i, s) -> i, Some s) - and dstart, localpart = + and dlen, localpart = rev jid |> find_mapi (fun i c -> if c = Uchar.of_char '@' - then Some (i, take i jid |> rev |> string_of_uchars) + then Some (i, take (length jid - i - 1) jid |> string_of_uchars) else None) |> Option.fold ~none:(0, None) ~some:(fun (i, s) -> i, Some s) in { localpart; resourcepart; - domainpart = drop dstart jid |> take (dend-dstart) |> string_of_uchars + domainpart = drop (dend-dlen) jid |> take dlen |> string_of_uchars } let%expect_test {|A "bare JID"|} = |