(cooked: string, raw: string)
| 245 | * @returns A object containing any metadata that was parsed from the message part. |
| 246 | */ |
| 247 | export function parseMetadata(cooked: string, raw: string): MessageMetadata { |
| 248 | const {text: messageString, block} = splitBlock(cooked, raw); |
| 249 | if (block === undefined) { |
| 250 | return {text: messageString}; |
| 251 | } else { |
| 252 | const [meaningDescAndId, ...legacyIds] = block.split(LEGACY_ID_INDICATOR); |
| 253 | const [meaningAndDesc, customId] = meaningDescAndId.split(ID_SEPARATOR, 2); |
| 254 | let [meaning, description]: (string | undefined)[] = meaningAndDesc.split(MEANING_SEPARATOR, 2); |
| 255 | if (description === undefined) { |
| 256 | description = meaning; |
| 257 | meaning = undefined; |
| 258 | } |
| 259 | if (description === '') { |
| 260 | description = undefined; |
| 261 | } |
| 262 | return {text: messageString, meaning, description, customId, legacyIds}; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Parse the given message part (`cooked` + `raw`) to extract any placeholder metadata from the |
no test coverage detected
searching dependent graphs…