UNPKG

pdf-to-png-converter-allow-yarn

Version:

Node.js utility to convert PDF file/buffer pages to PNG files/buffers with no native dependencies.

28 lines (27 loc) 839 B
"use strict"; 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 (process.platform === 'win32') { if (resolvedPath.endsWith('\\')) { return resolvedPath; } return `${resolvedPath}\\`; } if (resolvedPath.endsWith('/')) { return resolvedPath; } return `${resolvedPath}/`; }