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

std/url/join.ts>join

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function join
import { join } from "https://deno.land/std@0.209.0/url/join.ts";

Join a base URL and a series of paths, then normalizes the resulting URL.

Examples

Example 1

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

console.log(join("https://deno.land/", "std", "path", "mod.ts").href);
// Outputs: "https://deno.land/std/path/mod.ts"

console.log(join("https://deno.land", "//std", "path/", "/mod.ts").href);
// Outputs: "https://deno.land/path/mod.ts"

Parameters

url: string | URL

the base URL to be joined with the paths and normalized

...paths: string[]

array of path segments to be joined to the base URL

Returns

a complete URL string containing the base URL joined with the paths