( scriptContent: string, )
| 157 | * @returns Parsed parts, or null if no node file path was extracted |
| 158 | */ |
| 159 | export function parseNodeScript( |
| 160 | scriptContent: string, |
| 161 | ): { prefix: string; filePath: string } | null { |
| 162 | const match = NODE_SCRIPT_PATTERN.exec(scriptContent) |
| 163 | |
| 164 | if (match?.[1]) { |
| 165 | const filePath = match[1].replace(/^\.\//, '') |
| 166 | |
| 167 | // Fall back if path contains navigational elements |
| 168 | if (filePath.includes('../') || filePath.includes('./')) { |
| 169 | return null |
| 170 | } |
| 171 | |
| 172 | // Reconstruct the prefix (everything before the captured file path) |
| 173 | const prefix = scriptContent.slice(0, match.index + match[0].indexOf(match[1])) |
| 174 | return { prefix, filePath } |
| 175 | } |
| 176 | |
| 177 | return null |
| 178 | } |
no outgoing calls
no test coverage detected