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

import { isWindows } from "./_os.ts";
import { extname as posixExtname } from "./posix/extname.ts";
import { extname as windowsExtname } from "./windows/extname.ts";
/**
 * Return the extension of the path with leading period (".").
 *
 * @example Usage
 * ```ts
 * import { extname } from "@std/path/extname";
 * import { assertEquals } from "@std/assert/assert-equals";
 *
 * if (Deno.build.os === "windows") {
 *   assertEquals(extname("C:\\home\\user\\Documents\\image.png"), ".png");
 * } else {
 *   assertEquals(extname("/home/user/Documents/image.png"), ".png");
 * }
 * ```
 *
 * @param path Path with extension.
 * @returns The file extension. E.g. returns `.ts` for `file.ts`.
 */
export function extname(path: string): string {
  return isWindows ? windowsExtname(path) : posixExtname(path);
}

// denoCacheMetadata={"headers":{"alt-svc":"h3=\":443\"; ma=86400","x-robots-tag":"noindex","x-content-type-options":"nosniff","access-control-allow-origin":"*","cf-cache-status":"HIT","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';","cache-control":"public, max-age=31536000, immutable","cross-origin-resource-policy":"cross-origin","accept-ranges":"bytes","access-control-expose-headers":"*","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","etag":"\"ba7a217ab82ca1905724ff03803bd436\"","vary":"Origin","content-length":"920","date":"Tue, 28 Jul 2026 12:31:15 GMT","cf-ray":"a223e658bd517db6-LAX","age":"126790","server":"cloudflare","x-jsr-backend":"modules","content-type":"text/typescript","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=6FNAXzekUkGrG2cdbuj6i9XgyzDHHdH6LvnQ7PBDw4RdHwXWxq0L8yl9W1eQhnDtExabxVhaaGr8J42fmCGMocyRGDFOT9OH2SjdwNomWiC8T2r6R53uQDI%3D\"}]}","set-cookie":"__cf_bm=TDeg849VdJYBllHpU_cAqnZRXV.z_loEM2L6adeBOSQ-1785241875.319502-1.0.1.1-dN17hZ25RmIn88k2VM_BjFshcSbW2FZOSrYxxxrekWCEif5gVrsRkoHFr0NB69ifHQnSOr8nLScA_BClgPfDuOxdpVrBdal9lgOwOq.8Ck8GlBI_XJ95.AvZTP18x8NL; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT"},"url":"https://jsr.io/@std/path/1.0.0-rc.2/extname.ts","time":1785241875}