UNPKG

@chtsinc/ch-playwright-report

Version:

Custom Playwright Reporter that logs test and execution results to MongoDB

33 lines 1.05 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExtension = getExtension; exports.getContentType = getContentType; const path_1 = __importDefault(require("path")); /** * Extracts the file extension (without the dot) from a filename. * @param filename - The name (or path) of the file. * @returns The lowercase extension (e.g. "html"), or undefined if none. */ function getExtension(filename) { const ext = path_1.default.extname(filename); if (!ext) { return undefined; } return ext.slice(1).toLowerCase(); } function getContentType(ext) { switch (ext.toLowerCase()) { case "html": return "text/html"; case "webm": return "video/webm"; case "zip": return "application/zip"; default: return "application/octet-stream"; } } //# sourceMappingURL=file-util.js.map