(content: string)
| 31 | } |
| 32 | const MAX_JSON_FORMAT_LENGTH = 10_000; |
| 33 | export function tryJsonFormatContent(content: string): string { |
| 34 | if (content.length > MAX_JSON_FORMAT_LENGTH) { |
| 35 | return content; |
| 36 | } |
| 37 | const allLines = content.split('\n'); |
| 38 | return allLines.map(tryFormatJson).join('\n'); |
| 39 | } |
| 40 | |
| 41 | // Match http(s) URLs inside JSON string values. Conservative: no quotes, |
| 42 | // no whitespace, no trailing comma/brace that'd be JSON structure. |