JaBa/utils/resolve-file.js
2024-12-06 23:58:15 +03:00

11 lines
309 B
JavaScript

import path from "node:path";
/**
* Convert a local file path to a file URL.
* @param {string} filePath - local file's path.
* @returns {string} file URL
*/
export const toFileURL = filePath => {
const resolvedPath = path.resolve(filePath);
return "file://" + resolvedPath.replace(/\\\\|\\/g, "/");
};