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

View Documentation
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
/** * Utilities for working with * {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/URL | URL}s. * * This module is browser compatible. * * ## Get basename * * {@linkcode basename} returns the base name of a URL or URL string, optionally * removing a suffix. * * ```ts * import { basename } from "https://deno.land/std@$STD_VERSION/url/basename.ts"; * * basename("https://deno.land/std/assert/mod.ts"); // "mod.ts" * * basename(new URL("https://deno.land/std/assert/mod.ts")); // "mod.ts" * * basename("https://deno.land/std/assert/mod.ts?a=b"); // "mod.ts" * * basename("https://deno.land/std/assert/mod.ts#header"); // "mod.ts" * * basename("https://deno.land/"); // "deno.land" * ``` * * ## Get directory path * * {@linkcode dirname} returns the directory path of a URL or URL string. * * ```ts * import { dirname } from "https://deno.land/std@$STD_VERSION/url/dirname.ts"; * * dirname("https://deno.land/std/path/mod.ts?a=b").href; // "https://deno.land/std/path" * * dirname("https://deno.land/").href; // "https://deno.land" * ``` * * ## Get file extension * * {@linkcode extname} returns the file extension of a given URL or string with * leading period. * * ```ts * import { extname } from "https://deno.land/std@$STD_VERSION/url/extname.ts"; * * extname("https://deno.land/std/path/mod.ts"); // ".ts" * * extname("https://deno.land/std/path/mod"); // "" * * extname("https://deno.land/std/path/mod.ts?a=b"); // ".ts" * * extname("https://deno.land/"); // "" * ``` * * ## Join URL paths * * {@linkcode join} joins a base URL or URL string, and a sequence of path * segments together, then normalizes the resulting URL. * * ```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" * ``` * * ## Normalize URL * * {@linkcode normalize} normalizes the URL or URL string, resolving `..` and * `.` segments. Multiple sequential `/`s are resolved into a single `/`. * * ```ts * import { normalize } from "https://deno.land/std@$STD_VERSION/url/normalize.ts"; * * normalize("https:///deno.land///std//assert//.//mod.ts").href; * // "https://deno.land/std/path/mod.ts" * * normalize("https://deno.land/std/assert/../async/retry.ts").href; * // "https://deno.land/std/async/retry.ts" * ``` * * @module */
export * from "./basename.ts";export * from "./dirname.ts";export * from "./extname.ts";export * from "./join.ts";export * from "./normalize.ts";
std

Version Info

Tagged at
6 months ago