Comparing version 0.3.0 to 0.5.0
@@ -75,2 +75,3 @@ 'use strict' | ||
} | ||
getLocal(unescape) { | ||
@@ -96,2 +97,3 @@ unescape = unescape || false | ||
} | ||
getDomain() { | ||
@@ -108,2 +110,3 @@ return this._domain | ||
} | ||
getResource() { | ||
@@ -110,0 +113,0 @@ return this._resource |
@@ -7,3 +7,3 @@ { | ||
"bugs": "http://github.com/xmppjs/xmpp.js/issues", | ||
"version": "0.3.0", | ||
"version": "0.5.0", | ||
"license": "ISC", | ||
@@ -15,5 +15,9 @@ "keywords": [ | ||
"engines": { | ||
"node": ">= 6", | ||
"npm": ">= 2" | ||
} | ||
"node": ">= 10.0.0", | ||
"yarn": ">= 1.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "896f432d22dd726d158bd39a46aed7d53a2b7b1b" | ||
} |
@@ -1,11 +0,10 @@ | ||
JID | ||
=== | ||
# JID | ||
XMPP identifiers (JID) for JavaScript | ||
| JID type | local | @ | domain | / | resource | usage | | ||
|:--------:|:-----:|:-:|:--------------:|:-:|:----------:|:----------------------:| | ||
| domain | | | wonderland.net | | | servers and components | | ||
| bare | alice | @ | wonderland.net | | | users | | ||
| full | alice | @ | wonderland.net | / | rabbithole | user resource (device) | | ||
| JID type | local | @ | domain | / | resource | usage | | ||
| :------: | :---: | :-: | :------------: | :-: | :--------: | :--------------------: | | ||
| domain | | | wonderland.net | | | servers and components | | ||
| bare | alice | @ | wonderland.net | | | users | | ||
| full | alice | @ | wonderland.net | / | rabbithole | user resource (device) | | ||
@@ -16,5 +15,3 @@ https://en.wikipedia.org/wiki/XMPP#Decentralization_and_addressing | ||
``` | ||
npm install @xmpp/jid | ||
``` | ||
`npm install @xmpp/jid` or `yarn add @xmpp/jid` | ||
@@ -41,3 +38,3 @@ ## Usage | ||
addr.local = 'alice' | ||
addr.local // alice | ||
addr.local // alice | ||
// same as | ||
@@ -51,3 +48,3 @@ addr.setLocal('alice') | ||
addr.domain = 'wonderland.net' | ||
addr.domain // wonderland.net | ||
addr.domain // wonderland.net | ||
// same as | ||
@@ -61,3 +58,3 @@ addr.setDomain('wonderland.net') | ||
addr.resource = 'rabbithole' | ||
addr.resource // rabbithole | ||
addr.resource // rabbithole | ||
// same as | ||
@@ -68,3 +65,3 @@ addr.setResource('rabbithole') | ||
addr.toString() // alice@wonderland.net/rabbithole | ||
addr.bare() // returns a JID without resource | ||
addr.bare() // returns a JID without resource | ||
@@ -82,3 +79,3 @@ addr.equals(some_jid) // returns true if the two JIDs are equal, false otherwise | ||
const addr = jid('contact@example.net', 'xmpp.net') | ||
addr.toString() // contact\40example.net@xmpp.net | ||
addr.toString() // contact\40example.net@xmpp.net | ||
// for display purpose only | ||
@@ -98,9 +95,9 @@ addr.toString(true) // contact@example.net@xmpp.net | ||
* [RFC 7622 XMPP Address Format](https://tools.ietf.org/html/rfc7622) mostly implemented, l10n WIP | ||
* [XEP-0106 JID Escaping](https://xmpp.org/extensions/xep-0106.html) implemented | ||
- [RFC 7622 XMPP Address Format](https://tools.ietf.org/html/rfc7622) mostly implemented, l10n WIP | ||
- [XEP-0106 JID Escaping](https://xmpp.org/extensions/xep-0106.html) implemented | ||
### Deprecated | ||
* [XEP-0029 Definition of Jabber Identifiers (JIDs)](https://xmpp.org/extensions/xep-0029.html) 2003 | ||
* [RFC 3920 XMPP addressing](https://tools.ietf.org/html/rfc3920#section-3) 2004 | ||
* [RFC 3920 XMPP Address Format](https://tools.ietf.org/html/rfc6122) 2011 | ||
- [XEP-0029 Definition of Jabber Identifiers (JIDs)](https://xmpp.org/extensions/xep-0029.html) 2003 | ||
- [RFC 3920 XMPP addressing](https://tools.ietf.org/html/rfc3920#section-3) 2004 | ||
- [RFC 3920 XMPP Address Format](https://tools.ietf.org/html/rfc6122) 2011 |
@@ -7,10 +7,10 @@ 'use strict' | ||
test('Should not change string - issue 43', t => { | ||
const test = 'test\u001a@example.com' | ||
const test = 'test\u001A@example.com' | ||
const addr = jid(test) | ||
t.is(addr.local, 'test\u001a') | ||
t.is(addr.local, 'test\u001A') | ||
}) | ||
test('Should escape - issue 43', t => { | ||
const test = 'test\u001aa@example.com' | ||
const test = 'test\u001Aa@example.com' | ||
@@ -17,0 +17,0 @@ const addr = jid(test) |
@@ -84,8 +84,2 @@ 'use strict' | ||
test('escape `call me "ishmael"@example.com`', t => { | ||
const esc = new JID('call me "ishmael"', 'example.com') | ||
t.is(esc.toString(), 'call\\20me\\20\\22ishmael\\22@example.com') | ||
t.is(esc.toString(true), 'call me "ishmael"@example.com') | ||
}) | ||
test('escape `at\\26t\\20guy@example.com`', t => { | ||
@@ -133,8 +127,2 @@ const esc = new JID('at\\26t\\20guy', 'example.com') | ||
test('escape `c:\\\\net@example.com`', t => { | ||
const esc = new JID('c:\\\\net', 'example.com') | ||
t.is(esc.toString(), 'c\\3a\\5c\\5cnet@example.com') | ||
t.is(esc.toString(true), 'c:\\\\net@example.com') | ||
}) | ||
test('escape `c\\3a\\5ccool\\20stuff@example.com`', t => { | ||
@@ -141,0 +129,0 @@ const esc = new JID('c\\3a\\5ccool\\20stuff', 'example.com') |
19217
15
518
97