( fileContent: string, searchString: string, )
| 71 | * @returns The actual string found in the file, or null if not found |
| 72 | */ |
| 73 | export function findActualString( |
| 74 | fileContent: string, |
| 75 | searchString: string, |
| 76 | ): string | null { |
| 77 | // First try exact match |
| 78 | if (fileContent.includes(searchString)) { |
| 79 | return searchString |
| 80 | } |
| 81 | |
| 82 | // Try with normalized quotes |
| 83 | const normalizedSearch = normalizeQuotes(searchString) |
| 84 | const normalizedFile = normalizeQuotes(fileContent) |
| 85 | |
| 86 | const searchIndex = normalizedFile.indexOf(normalizedSearch) |
| 87 | if (searchIndex !== -1) { |
| 88 | // Find the actual string in the file that matches |
| 89 | return fileContent.substring(searchIndex, searchIndex + searchString.length) |
| 90 | } |
| 91 | |
| 92 | return null |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * When old_string matched via quote normalization (curly quotes in file, |
no test coverage detected