comparison util.js @ 1:d6df73b466f6

Implement XEP-0156 to discover the right BOSH endpoint.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 21 Dec 2018 23:44:18 +0100
parents
children 5aa1bf7154b0
comparison
equal deleted inserted replaced
0:2a8d4e8600d0 1:d6df73b466f6
1 function nsResolver(prefix) {
2 return {
3 xrd: 'http://docs.oasis-open.org/ns/xri/xrd-1.0',
4 pubsub: 'http://jabber.org/protocol/pubsub',
5 avatar_metadata: 'urn:xmpp:avatar:metadata',
6 avatar_data: 'urn:xmpp:avatar:data',
7 nickname: 'http://jabber.org/protocol/nick',
8 }[prefix] || null;
9 }
10
11 function parseXPath(elem, xpath, result)
12 {
13 if (result === undefined)
14 result = XPathResult.FIRST_ORDERED_NODE_TYPE;
15 const value = elem.getRootNode().evaluate(xpath, elem, nsResolver, result, null);
16 if (result == XPathResult.FIRST_ORDERED_NODE_TYPE)
17 return value.singleNodeValue;
18 return value;
19 }