Skip to main content
This package has been archived, and as such it is read-only.

@std/url@0.225.1
Built and signed on GitHub Actions

DEPRECATED: now use path APIs directly

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 months ago (0.225.1)
function dirname
dirname(url: string | URL): URL
Deprecated

Use @std/path/dirname instead. @std/url will be removed in the future.

Returns the directory path URL of a URL or URL string.

The directory path is the portion of a URL up to but excluding the final path segment. URL queries and hashes are ignored.

Examples

Usage

import { dirname } from "@std/url/dirname";
import { assertEquals } from "@std/assert";

assertEquals(dirname("https://deno.land/std/path/mod.ts"), new URL("https://deno.land/std/path"));
assertEquals(dirname(new URL("https://deno.land/std/path/mod.ts")), new URL("https://deno.land/std/path"));

Parameters

url: string | URL

URL to extract the directory from.

Return Type

The directory path URL of the URL.

Add Package

deno add jsr:@std/url

Import symbol

import { dirname } from "@std/url/dirname";

---- OR ----

Import directly with a jsr specifier

import { dirname } from "jsr:@std/url/dirname";

Add Package

npx jsr add @std/url

Import symbol

import { dirname } from "@std/url/dirname";

Add Package

yarn dlx jsr add @std/url

Import symbol

import { dirname } from "@std/url/dirname";

Add Package

pnpm dlx jsr add @std/url

Import symbol

import { dirname } from "@std/url/dirname";

Add Package

bunx jsr add @std/url

Import symbol

import { dirname } from "@std/url/dirname";