MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / parseFileTransformReference

Function parseFileTransformReference

src/providers/transformUtils.ts:12–32  ·  view source on GitHub ↗
(reference: string)

Source from the content-addressed store, hash-verified

10}
11
12export 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.

Callers 5

createSessionParserFunction · 0.90
createValidateStatusFunction · 0.90
createStreamResponseFunction · 0.90
loadTransformModuleFunction · 0.85

Calls 1

isJavascriptFileFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…