UNPKG

yahoo-finance2

Version:
36 lines (35 loc) 1.36 kB
"use strict"; // Copyright 2018-2025 the Deno authors. MIT license. // This module is browser compatible. Object.defineProperty(exports, "__esModule", { value: true }); exports.normalize = normalize; const os_js_1 = require("../../internal/1.0.13/os.js"); const normalize_js_1 = require("./posix/normalize.js"); const normalize_js_2 = require("./windows/normalize.js"); /** * Normalize the path, resolving `'..'` and `'.'` segments. * * Note: Resolving these segments does not necessarily mean that all will be * eliminated. A `'..'` at the top-level will be preserved, and an empty path is * canonically `'.'`. * * @example Usage * ```ts * import { normalize } from "@std/path/normalize"; * import { assertEquals } from "@std/assert"; * * if (Deno.build.os === "windows") { * assertEquals(normalize("C:\\foo\\bar\\..\\baz\\quux"), "C:\\foo\\baz\\quux"); * assertEquals(normalize(new URL("file:///C:/foo/bar/../baz/quux")), "C:\\foo\\baz\\quux"); * } else { * assertEquals(normalize("/foo/bar/../baz/quux"), "/foo/baz/quux"); * assertEquals(normalize(new URL("file:///foo/bar/../baz/quux")), "/foo/baz/quux"); * } * ``` * * @param path Path to be normalized * @returns The normalized path. */ function normalize(path) { return os_js_1.isWindows ? (0, normalize_js_2.normalize)(path) : (0, normalize_js_1.normalize)(path); }