Function basename
- basename(path, suffix?): string
Parameters
- path: string
Path to extract the name from.
- suffix: string = ""
Suffix to remove from extracted name.
Returns string
The basename of the path.
Example: Usage
import { basename } from "@std/path/basename";
import { assertEquals } from "@std/assert";
if (Deno.build.os === "windows") {
assertEquals(basename("C:\\user\\Documents\\image.png"), "image.png");
} else {
assertEquals(basename("/home/user/Documents/image.png"), "image.png");
}Note: If you are working with file URLs, use the new version of
basenamefrom@std/path/unstable-basename.- path: string
Return the last portion of a path.
The trailing directory separators are ignored, and optional suffix is removed.