pdf-to-png-converter
Version:
Node.js utility to convert PDF file/buffer pages to PNG files/buffers with no native dependencies.
22 lines (21 loc) • 669 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePath = normalizePath;
const node_path_1 = require("node:path");
/**
* Normalizes a given path by ensuring it ends with the appropriate path separator.
*
* @param path - The path to be normalized.
* @returns The normalized path.
* @throws Error if the path is empty.
*/
function normalizePath(path) {
if (path === '') {
throw new Error('Path cannot be empty');
}
const resolvedPath = (0, node_path_1.normalize)((0, node_path_1.resolve)(path));
if (resolvedPath.endsWith('/')) {
return resolvedPath;
}
return `${resolvedPath}/`;
}