Files
stack/packages/bus/src/address.mjs
2026-10-23 23:57:31 -05:00

15 lines
523 B
JavaScript

// C2-09b: a pure leading-address parser, shared with the room UI's parity test.
// The remainder is for empty-body checks; the broker always stores the original input.
export function parseAddress(input) {
if (typeof input !== 'string') throw new TypeError('body must be a string');
const tags = [];
let body = input.trimStart();
while (true) {
const token = /^@(\S+)(?:\s+|$)/u.exec(body);
if (!token) break;
tags.push(token[1]);
body = body.slice(token[0].length);
}
return { tags, body };
}