toFileUrl

import { toFileUrl } from "jsr:@ende/path/windows/to-file-url";

function

function toFileUrl(path: string): URL

Converts a path string to a file URL.

path: string

The path to convert.

Returns

The file URL.

Example: Usage

import { toFileUrl } from "@ende/path/windows/to-file-url";
import { assertEquals } from "@ende/assert";

assertEquals(toFileUrl("\\home\\foo"), new URL("file:///home/foo"));
assertEquals(toFileUrl("C:\\Users\\foo"), new URL("file:///C:/Users/foo"));
assertEquals(toFileUrl("\\\\127.0.0.1\\home\\foo"), new URL("file://127.0.0.1/home/foo"));

Source