( line: string, json: Record<string, unknown> | null, jsonKeys: string[], )
| 348 | } |
| 349 | |
| 350 | function readBody( |
| 351 | line: string, |
| 352 | json: Record<string, unknown> | null, |
| 353 | jsonKeys: string[], |
| 354 | ): string | undefined { |
| 355 | if (json) { |
| 356 | for (const key of jsonKeys) { |
| 357 | if (json[key] !== undefined) return stringifyValue(json[key]); |
| 358 | } |
| 359 | } |
| 360 | for (const key of jsonKeys) { |
| 361 | const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
| 362 | const regex = new RegExp(`\\b${escaped}["'=: ]+(.+)$`, 'i'); |
| 363 | const match = regex.exec(line); |
| 364 | if (match?.[1]) return match[1].trim(); |
| 365 | } |
| 366 | return undefined; |
| 367 | } |
| 368 | |
| 369 | function stringifyValue(value: unknown): string { |
| 370 | if (typeof value === 'string') return value; |
no test coverage detected
searching dependent graphs…