Skip to content

Function: sanitizeFilePath()

ts
function sanitizeFilePath(filePath: string): string;

Defined in: src/file/mwFile.ts:152

Sanitize and normalize a file path to prevent command injection.

Rejects relative paths. Returns the normalized absolute path.

Parameters

ParameterTypeDescription
filePathstringThe absolute path to sanitize.

Returns

string

The normalized, safe file path.

Example

ts
const safe = sanitizeFilePath('/home/user/docs/../reports/q4.pdf');
console.log(safe); // '/home/user/reports/q4.pdf'

Matterway Assistant SDK Documentation