mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
lib/irc: escape/unescape everything in tags
Without the greedy flag on the regexp, String.replace will just replace the first match. While at it, also make sure to convert to a string when formatting tag values. This allows tag values to be e.g. numbers.
This commit is contained in:
parent
2d4409e7aa
commit
8ab10cf2a5
1 changed files with 2 additions and 2 deletions
|
@ -43,11 +43,11 @@ const tagEscapeMap = {
|
|||
const tagUnescapeMap = Object.fromEntries(Object.entries(tagEscapeMap).map(([from, to]) => [to, from]));
|
||||
|
||||
function escapeTag(s) {
|
||||
return s.replace(/[; \\\r\n]/, (ch) => tagEscapeMap[ch]);
|
||||
return String(s).replace(/[; \\\r\n]/g, (ch) => tagEscapeMap[ch]);
|
||||
}
|
||||
|
||||
function unescapeTag(s) {
|
||||
return s.replace(/\\[:s\\rn]/, (seq) => tagUnescapeMap[seq]);
|
||||
return s.replace(/\\[:s\\rn]/g, (seq) => tagUnescapeMap[seq]);
|
||||
}
|
||||
|
||||
export function parseTags(s) {
|
||||
|
|
Loading…
Reference in a new issue