21 lines
413 B
JavaScript
21 lines
413 B
JavaScript
import JID from "./JID.js";
|
|
|
|
export default function parse(s) {
|
|
let local;
|
|
let resource;
|
|
|
|
const resourceStart = s.indexOf("/");
|
|
if (resourceStart !== -1) {
|
|
resource = s.slice(resourceStart + 1);
|
|
s = s.slice(0, resourceStart);
|
|
}
|
|
|
|
const atStart = s.indexOf("@");
|
|
if (atStart !== -1) {
|
|
local = s.slice(0, atStart);
|
|
s = s.slice(atStart + 1);
|
|
}
|
|
|
|
return new JID(local, s, resource);
|
|
}
|