mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-04 09:43:03 +05:00
12 lines
309 B
JavaScript
12 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, "/");
|
||
|
};
|