import { IRCMessageTags } from "../irc/tags" ; const decodeMap = { "\\\\" : "\\" , "\\:" : ";" , "\\s" : " " , "\\n" : "\n" , "\\r" : "\r" , "\\" : "" , } ; const decodeLookupRegex = /\\\\|\\:|\\s|\\n|\\r|\\/g ; export function decodeValue ( value ) { if ( value == null ) { return null ; } return value . replace ( decodeLookupRegex , ( m ) => decodeMap [ m ] || "" ) ; } export function parseTags ( tagsSrc ) { const tags = { } ; if ( tagsSrc == null ) { return tags ; } for ( const tagSrc of tagsSrc . split ( ";" ) ) { let key ; let valueSrc ; [ key , valueSrc ] = tagSrc . split ( "=" , 2 ) ; tags [ key . toLowerCase ( ) ] = decodeValue ( valueSrc ) ; } return tags ; }