@vizzly-testing/cli
Version:
Visual review platform for UI developers and designers
31 lines (30 loc) • 1.5 kB
TypeScript
/**
* Sanitizes a screenshot name to prevent path traversal and ensure safe file naming
* @param {string} name - Original screenshot name
* @param {number} maxLength - Maximum allowed length (default: 255)
* @param {boolean} allowSlashes - Whether to allow forward slashes (for browser version strings)
* @returns {string} Sanitized screenshot name
*/
export function sanitizeScreenshotName(name: string, maxLength?: number, allowSlashes?: boolean): string;
/**
* Validates that a path stays within the allowed working directory bounds
* @param {string} targetPath - Path to validate
* @param {string} workingDir - Working directory that serves as the security boundary
* @returns {string} Resolved and normalized path if valid
* @throws {Error} If path is invalid or outside bounds
*/
export function validatePathSecurity(targetPath: string, workingDir: string): string;
/**
* Safely constructs a path within the working directory
* @param {string} workingDir - Base working directory
* @param {...string} pathSegments - Path segments to join
* @returns {string} Safely constructed path
* @throws {Error} If resulting path would be outside working directory
*/
export function safePath(workingDir: string, ...pathSegments: string[]): string;
/**
* Validates screenshot properties object for safe values
* @param {Object} properties - Properties to validate
* @returns {Object} Validated properties object
*/
export function validateScreenshotProperties(properties?: any): any;