mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
lib/irc: accept tags without value
This commit is contained in:
parent
4257463b46
commit
2d4409e7aa
1 changed files with 11 additions and 7 deletions
18
lib/irc.js
18
lib/irc.js
|
@ -52,18 +52,18 @@ function unescapeTag(s) {
|
|||
|
||||
export function parseTags(s) {
|
||||
var tags = {};
|
||||
s.split(";").forEach(function(s) {
|
||||
s.split(";").forEach((s) => {
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
var parts = s.split("=", 2);
|
||||
if (parts.length != 2) {
|
||||
throw new Error("expected an equal sign in tag");
|
||||
}
|
||||
var k = parts[0];
|
||||
var v = unescapeTag(parts[1]);
|
||||
if (v.endsWith("\\")) {
|
||||
v = v.slice(0, v.length - 1)
|
||||
var v = null;
|
||||
if (parts.length == 2) {
|
||||
v = unescapeTag(parts[1]);
|
||||
if (v.endsWith("\\")) {
|
||||
v = v.slice(0, v.length - 1)
|
||||
}
|
||||
}
|
||||
tags[k] = v;
|
||||
});
|
||||
|
@ -73,6 +73,10 @@ export function parseTags(s) {
|
|||
export function formatTags(tags) {
|
||||
var l = [];
|
||||
for (var k in tags) {
|
||||
if (tags[k] === undefined || tags[k] === null) {
|
||||
l.push(k);
|
||||
continue;
|
||||
}
|
||||
var v = escapeTag(tags[k]);
|
||||
l.push(k + "=" + v);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue