(reference: string)
| 10 | } |
| 11 | |
| 12 | export function parseFileTransformReference(reference: string): FileTransformReference { |
| 13 | const rawFilename = reference.startsWith('file://') |
| 14 | ? reference.slice('file://'.length) |
| 15 | : reference; |
| 16 | const lastColonIndex = rawFilename.lastIndexOf(':'); |
| 17 | |
| 18 | if (lastColonIndex === -1) { |
| 19 | return { filename: rawFilename }; |
| 20 | } |
| 21 | |
| 22 | const candidateFilename = rawFilename.slice(0, lastColonIndex); |
| 23 | const candidateFunctionName = rawFilename.slice(lastColonIndex + 1); |
| 24 | if (candidateFilename && candidateFunctionName && isJavascriptFile(candidateFilename)) { |
| 25 | return { |
| 26 | filename: candidateFilename, |
| 27 | functionName: candidateFunctionName, |
| 28 | }; |
| 29 | } |
| 30 | |
| 31 | return { filename: rawFilename }; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Loads a module from a file:// reference if needed. |
no test coverage detected
searching dependent graphs…