deno.land / std@0.224.0 / url / join.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
import { join as posixJoin } from "../path/posix/join.ts";
/** * Joins a base URL or URL string, and a sequence of path segments together, * then normalizes the resulting URL. * * @param url Base URL to be joined with the paths and normalized. * @param paths Array of path segments to be joined to the base URL. * @returns A complete URL containing the base URL joined with the paths. * * @example Basic usage * ```ts * import { join } from "https://deno.land/std@$STD_VERSION/url/join.ts"; * * join("https://deno.land/", "std", "path", "mod.ts").href; * // "https://deno.land/std/path/mod.ts" * * join("https://deno.land", "//std", "path/", "/mod.ts").href; * // "https://deno.land/path/mod.ts" * ``` */export function join(url: string | URL, ...paths: string[]): URL { url = new URL(url); url.pathname = posixJoin(url.pathname, ...paths); return url;}
std

Version Info

Tagged at
3 weeks ago