fromFileUrl

import { fromFileUrl } from "jsr:@ende/path";

function

function fromFileUrl(url: string | URL): string

Converts a file URL to a path string.

url: string | URL

The file URL to convert to a path.

Returns

The path string.

Example: Usage

import { fromFileUrl } from "@ende/path/from-file-url";
import { assertEquals } from "@ende/assert";

if (Ende.build.os === "windows") {
  assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo");
  assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo");
  assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo");
} else {
  assertEquals(fromFileUrl("file:///home/foo"), "/home/foo");
}

Source