diff options
-rw-r--r-- | portal/lib/portal_ws.ml | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/portal/lib/portal_ws.ml b/portal/lib/portal_ws.ml index 366f524..5377ed9 100644 --- a/portal/lib/portal_ws.ml +++ b/portal/lib/portal_ws.ml @@ -18,21 +18,21 @@ let ws_endpoint (domain : string) = let+ host_meta = Js_of_ocaml_lwt.XmlHttpRequest.perform_raw_url (well_known_of domain) in let i = Xmlm.make_input (`String (0, host_meta.content)) (* This ugly function extracts the href element from a Link tag's attributes if it's a websocket. *) - and link_websocket attrs = - match attrs with + and link_websocket = function + | ((_, "rel"), "urn:xmpp:alt-connections:websocket") :: ((_, "href"), href) :: _ | ((_, "href"), href) :: ((_, "rel"), "urn:xmpp:alt-connections:websocket") :: _ -> Some href - | ((_, "rel"), "urn:xmpp:alt-connections:websocket") :: ((_, "href"), href) :: _ -> Some href | _ -> None - in let parse_tree = (* Parse a single XRD tree. *) + in let parse_xrd = (* Parse a single XRD tree. *) Xmlm.input_tree ~el:(fun tag children -> match tag with | ((_, "Link"), attributes) -> link_websocket attributes | ((_, "XRD"), _) -> List.find_map (fun x -> x) children | _ -> None) - ~data:(fun x -> Some x) - in ignore (Xmlm.input i); (* DTD *) - match parse_tree i with + (* The XRD tree doesn't hold any relevant XML data. *) + ~data:(fun _ -> None) + in ignore (Xmlm.input i); (* DTD stuff *) + match parse_xrd i with | Some uri -> uri | None -> failwith (domain ^ "doesn't advertise a WebSocket endpoint via Web-host Metadata.") |