import { basename } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/path.js";
Return the last portion of the given path
. Trailing directory separators
are ignored, and optional suffix
is removed.
Examples
Example 1
Example 1
import { basename } from "@ayonli/jsext/path";
console.log(basename("/foo/bar")); // "bar"
console.log(basename("c:\\foo\\bar")); // "bar"
console.log(basename("file:///foo/bar")); // "bar"
console.log(basename("http://example.com/foo/bar")); // "bar"
console.log(basename("http://example.com/foo/bar?foo=bar#baz")); // "bar"
console.log(basename("http://example.com/foo/bar.txt?foo=bar#baz", ".txt")); // "bar"