All files / fs / _to_path_string.ts

100.00% Branches 2/2
100.00% Lines 5/5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
 
 
x22
 
 
 
 
 
 
 
 
x22
x22
 
x807
x807















// Copyright 2018-2025 the Deno authors. MIT license.
// Copyright the Browserify authors. MIT License.

import { fromFileUrl } from "@std/path/from-file-url";

/**
 * Convert a URL or string to a path.
 *
 * @param pathUrl A URL or string to be converted.
 *
 * @returns The path as a string.
 */
export function toPathString(
  pathUrl: string | URL,
): string {
  return pathUrl instanceof URL ? fromFileUrl(pathUrl) : pathUrl;
}