( line: ParsedGrepLine, mode: GrepMode, pathClass: PathClass, )
| 720 | } |
| 721 | |
| 722 | function parsedFilePath( |
| 723 | line: ParsedGrepLine, |
| 724 | mode: GrepMode, |
| 725 | pathClass: PathClass, |
| 726 | ): string | undefined { |
| 727 | if (line.kind === 'record') return normalize(line.filePath); |
| 728 | if (line.kind === 'separator') return undefined; |
| 729 | const text = line.text; |
| 730 | if (mode === 'files_with_matches') return normalize(text); |
| 731 | if (mode === 'count_matches') { |
| 732 | const idx = text.lastIndexOf(':'); |
| 733 | return idx > 0 ? normalize(text.slice(0, idx)) : normalize(text); |
| 734 | } |
| 735 | return extractContentFilePath(text, pathClass); |
| 736 | } |
| 737 | |
| 738 | function extractContentFilePath(line: string, pathClass: PathClass): string | undefined { |
| 739 | const m = CONTENT_LINE_RE.exec(line); |
no test coverage detected