Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/url/extname.ts>extname

Deno standard library
Go to Latest
function extname
import { extname } from "https://deno.land/std@0.208.0/url/extname.ts";

Return the extension of the URL with leading period. The extension is sourced from the path portion of the URL. If there is no extension, an empty string is returned.

Examples

Example 1

import { extname } from "https://deno.land/std@0.208.0/url/extname.ts";

console.log(extname("https://deno.land/std/path/mod.ts")); // ".ts"
console.log(extname("https://deno.land/std/path/mod")); // ""
console.log(extname("https://deno.land/std/path/mod.ts?a=b")); // ".ts"
console.log(extname("https://deno.land/")); // ""

Parameters

url: string | URL

with extension

Returns

string

extension (e.g. for url ending with index.html returns .html)