// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { isWindows } from "./_os.ts";
import { dirname as posixDirname } from "./posix/dirname.ts";
import { dirname as windowsDirname } from "./windows/dirname.ts";

/**
 * Return the directory path of a `path`.
 * @param path - path to extract the directory from.
 */
export function dirname(path: string): string {
  return isWindows ? windowsDirname(path) : posixDirname(path);
}

// denoCacheMetadata={"headers":{"cross-origin-resource-policy":"cross-origin","date":"Tue, 28 Jul 2026 12:31:15 GMT","content-type":"text/typescript","content-length":"498","cache-control":"public, max-age=31536000, immutable","access-control-expose-headers":"*","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","x-jsr-backend":"modules","x-content-type-options":"nosniff","set-cookie":"__cf_bm=FUYOlIYCWC9Wfoqjvknw02ETx6DDr30NoKx._5CSePE-1785241875.139483-1.0.1.1-j548FC79nqKv4TzC0_vkA1NsccNJ5K7EPabKvjA2RssPhAYELgtlxSzuBjM0sjY3LNX3dMtrbAyLeZBtDIsMn0WWvj03UO8rVsV0mjFSkGMVEeirVFoSt9r1IINwNR4j; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","vary":"Origin","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=2TISM8y0pYdKG842qNGpGwvbxRFjCWMGwgVsfr1yR58%2FFWD%2BQf7jNneiH2BUT4VIwc8Prs6vmD%2BaVEAUG82r618onjZy5XX3lDVeXXhQriQHOiJOh8aq5Is%3D\"}]}","cf-cache-status":"HIT","x-robots-tag":"noindex","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","server":"cloudflare","etag":"\"4628881f519bbe6543ae3ace61a1a660\"","cf-ray":"a223e6579a0e7db6-LAX","alt-svc":"h3=\":443\"; ma=86400","access-control-allow-origin":"*","accept-ranges":"bytes","age":"4037548"},"url":"https://jsr.io/@std/path/0.224.0/dirname.ts","time":1785241875}