15 lines
523 B
JavaScript
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 };
|
|
}
|