UNPKG

reviewit

Version:

A lightweight command-line tool that spins up a local web server to display Git commit diffs in a GitHub-like Files changed view

22 lines (21 loc) 573 B
/** * Get file extension from filename or filepath * @param filename - The filename or filepath * @returns The file extension in lowercase, or null if no extension */ export function getFileExtension(filename) { if (!filename) return null; const extension = filename.split('.').pop()?.toLowerCase(); return extension || null; } /** * Get filename from filepath * @param filepath - The filepath * @returns The filename */ export function getFileName(filepath) { if (!filepath) return ''; return filepath.split('/').pop() || ''; }