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

Function parseFilePathAndFunctionName

src/util/transform.ts:55–62  ·  view source on GitHub ↗

* Parses a file path string to extract the file path and function name. * Handles Windows drive letters (e.g., C:\path\to\file.js:functionName). * @param filePath - The file path string, potentially including a function name. * @returns A tuple containing the file path and function name (if prese

(filePath: string)

Source from the content-addressed store, hash-verified

53 * @returns A tuple containing the file path and function name (if present).
54 */
55function parseFilePathAndFunctionName(filePath: string): [string, string | undefined] {
56 const lastColonIndex = filePath.lastIndexOf(':');
57 // Check if colon is part of Windows drive letter (position 1) or not present
58 if (lastColonIndex > 1) {
59 return [filePath.slice(0, lastColonIndex), filePath.slice(lastColonIndex + 1)];
60 }
61 return [filePath, undefined];
62}
63
64/**
65 * Retrieves a JavaScript transform function from a file.

Callers 1

getFileTransformFunctionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…