All files / backend/dist/utils content-formats.js

14.28% Statements 1/7
0% Branches 0/7
0% Functions 0/2
14.28% Lines 1/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31          1x                                                  
/**
 * Content Format Utilities
 *
 * Functions for identifying and validating content file types.
 */
export const SUPPORTED_CONTENT_EXTENSIONS = ['md', 'markdown', 'html', 'qmd'];
/**
 * Check if a file path has a valid content file extension
 * @param filePath - Path to check
 * @returns True if the file has a supported content extension
 */
export function allValidContentFilesExt(filePath) {
    return Boolean(filePath &&
        (filePath.endsWith('.md') ||
            filePath.endsWith('.markdown') ||
            filePath.endsWith('.qmd') ||
            filePath.endsWith('.html')));
}
/**
 * Check if a file is a content file based on its extension
 * @param filePath - Path to check
 * @returns True if the file is a content file
 */
export function isContentFile(filePath) {
    if (filePath === undefined)
        return false;
    const parts = filePath.split('.');
    const extension = parts[parts.length - 1];
    return SUPPORTED_CONTENT_EXTENSIONS.includes(extension);
}