Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/path.ts>dirname

A JavaScript extension package for building strong and modern applications.
Latest
function dirname
import { dirname } from "https://deno.land/x/ayonli_jsext@v0.9.72/path.ts";

Returns the parent path of the given path.

Examples

Example 1

import { dirname } from "@ayonli/jsext/path";

console.log(dirname("foo/bar")); // "foo"
console.log(dirname("/foo/bar")); // "/foo"
console.log(dirname("C:\\foo\\bar")); // "C:\\foo"
console.log(dirname("file:///foo/bar")); // "file:///foo"
console.log(dirname("http://example.com/foo/bar")); // "http://example.com/foo"
console.log(dirname("http://example.com/foo")); // "http://example.com"
console.log(dirname("http://example.com/foo/bar?foo=bar#baz")); // "http://example.com/foo"

Parameters

path: string

Returns

string