Skip to main content
Home
This release is 15 versions behind 1.1.4 — the latest version of @std/path. Jump to latest

@std/path@0.225.2
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Deno, Browsers
This package works with Cloudflare Workers
This package works with Deno
This package works with Browsers
JSR Score94%
Downloads136,652/wk
Published2 years ago (0.225.2)

Utilities for working with file system paths

// 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); }