diff --git a/_tools/check_circular_package_dependencies.ts b/_tools/check_circular_package_dependencies.ts index 79bb26cf6fad..eaf5573f925c 100644 --- a/_tools/check_circular_package_dependencies.ts +++ b/_tools/check_circular_package_dependencies.ts @@ -70,7 +70,6 @@ type Mod = | "text" | "toml" | "ulid" - | "url" | "uuid" | "webgpu" | "yaml"; @@ -111,7 +110,6 @@ const ENTRYPOINTS: Record = { text: ["mod.ts"], toml: ["mod.ts"], ulid: ["mod.ts"], - url: ["mod.ts"], uuid: ["mod.ts"], webgpu: ["mod.ts"], yaml: ["mod.ts"], diff --git a/_tools/check_docs.ts b/_tools/check_docs.ts index 95ee6875101f..ebdacd403353 100644 --- a/_tools/check_docs.ts +++ b/_tools/check_docs.ts @@ -69,7 +69,6 @@ const ENTRY_POINTS = [ "../testing/types.ts", "../toml/mod.ts", "../ulid/mod.ts", - "../url/mod.ts", "../uuid/mod.ts", "../webgpu/mod.ts", "../yaml/mod.ts", diff --git a/deno.json b/deno.json index d29732e606fe..f512dfbfd7bb 100644 --- a/deno.json +++ b/deno.json @@ -47,7 +47,6 @@ "@std/text": "jsr:@std/text@^1.0.2", "@std/toml": "jsr:@std/toml@^1.0.0", "@std/ulid": "jsr:@std/ulid@^1.0.0", - "@std/url": "jsr:@std/url@^0.225.0", "@std/uuid": "jsr:@std/uuid@^1.0.0", "@std/webgpu": "jsr:@std/webgpu@^0.224.5", "@std/yaml": "jsr:@std/yaml@^1.0.2" @@ -128,7 +127,6 @@ "./text", "./toml", "./ulid", - "./url", "./uuid", "./webgpu", "./yaml" diff --git a/url/_strip.ts b/url/_strip.ts deleted file mode 100644 index 520cae1d1e66..000000000000 --- a/url/_strip.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -/** - * Strips any hash (eg. `#header`) or search parameters (eg. `?foo=bar`) from the provided URL. - * - * (Mutates the original url provided) - * @param url to be stripped. - */ -export function strip(url: URL) { - url.hash = ""; - url.search = ""; -} diff --git a/url/basename.ts b/url/basename.ts deleted file mode 100755 index 72469ec4e303..000000000000 --- a/url/basename.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -import { basename as posixBasename } from "@std/path/posix/basename"; -import { strip } from "./_strip.ts"; - -/** - * Returns the base name of a URL or URL string, optionally removing a suffix. - * - * Trailing `/`s are ignored. If no path is present, the host name is returned. - * If a suffix is provided, it will be removed from the base name. URL queries - * and hashes are ignored. - * - * @param url The URL from which to extract the base name. - * @param suffix An optional suffix to remove from the base name. - * @returns The base name of the URL. - * - * @example Basic usage - * ```ts - * import { basename } from "@std/url/basename"; - * import { assertEquals } from "@std/assert"; - * - * assertEquals(basename("https://deno.land/std/assert/mod.ts"), "mod.ts"); - * assertEquals(basename(new URL("https://deno.land/std/assert/mod.ts")), "mod.ts"); - * assertEquals(basename("https://deno.land/std/assert/mod.ts?a=b"), "mod.ts"); - * assertEquals(basename("https://deno.land/std/assert/mod.ts#header"), "mod.ts"); - * assertEquals(basename("https://deno.land/"), "deno.land"); - * ``` - * - * @example Removing a suffix - * - * Defining a suffix will remove it from the base name. - * - * ```ts - * import { basename } from "@std/url/basename"; - * import { assertEquals } from "@std/assert"; - * - * assertEquals(basename("https://deno.land/std/assert/mod.ts", ".ts"), "mod"); - * assertEquals(basename(new URL("https://deno.land/std/assert/mod.ts"), ".ts"), "mod"); - * assertEquals(basename("https://deno.land/std/assert/mod.ts?a=b", ".ts"), "mod"); - * assertEquals(basename("https://deno.land/std/assert/mod.ts#header", ".ts"), "mod"); - * ``` - * - * @deprecated Use - * {@linkcode https://jsr.io/@std/path/doc/posix/~/basename | @std/path/posix/basename} - * instead (examples included). `@std/url` will be removed in the future. - */ -export function basename(url: string | URL, suffix?: string): string { - url = new URL(url); - strip(url); - return posixBasename(url.href, suffix); -} diff --git a/url/basename_test.ts b/url/basename_test.ts deleted file mode 100755 index 499a637fc331..000000000000 --- a/url/basename_test.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -import { assertEquals } from "@std/assert"; -import * as url from "./mod.ts"; - -const TESTSUITE: [[string | URL, string?], string][] = [ - [["https://deno.land/std/assert/mod.ts"], "mod.ts"], - [[new URL("https://deno.land/std/assert/mod.ts")], "mod.ts"], - [[new URL("https://deno.land/std/assert/mod.ts"), ".ts"], "mod"], - [[new URL("https://deno.land/std/assert/mod.ts?foo=bar")], "mod.ts"], - [[new URL("https://deno.land/std/assert/mod.ts#header")], "mod.ts"], - [[new URL("https://deno.land///")], "deno.land"], -]; - -Deno.test("basename()", function () { - for (const [[testUrl, suffix], expected] of TESTSUITE) { - assertEquals(url.basename(testUrl, suffix), expected); - } -}); diff --git a/url/deno.json b/url/deno.json deleted file mode 100644 index 582e06624fe9..000000000000 --- a/url/deno.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@std/url", - "version": "0.225.0", - "exports": { - ".": "./mod.ts", - "./basename": "./basename.ts", - "./dirname": "./dirname.ts", - "./extname": "./extname.ts", - "./join": "./join.ts", - "./normalize": "./normalize.ts" - } -} diff --git a/url/dirname.ts b/url/dirname.ts deleted file mode 100755 index 0e6c5c8e6dc7..000000000000 --- a/url/dirname.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -import { dirname as posixDirname } from "@std/path/posix/dirname"; -import { strip } from "./_strip.ts"; - -/** - * 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. - * - * @param url URL to extract the directory from. - * @returns The directory path URL of the URL. - * - * @example Usage - * ```ts - * 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")); - * ``` - * - * @deprecated Use - * {@linkcode https://jsr.io/@std/path/doc/posix/~/dirname | @std/path/posix/dirname} - * instead (examples included). `@std/url` will be removed in the future. - */ - -export function dirname(url: string | URL): URL { - url = new URL(url); - strip(url); - url.pathname = posixDirname(url.pathname); - return url; -} diff --git a/url/dirname_test.ts b/url/dirname_test.ts deleted file mode 100755 index 4231fcf729fe..000000000000 --- a/url/dirname_test.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -import { assertEquals } from "@std/assert"; -import * as url from "./mod.ts"; - -const TESTSUITE = [ - [ - "https://deno.land/std/assert/mod.ts", - new URL("https://deno.land/std/assert"), - ], - [ - new URL("https://deno.land/std/assert/mod.ts"), - new URL("https://deno.land/std/assert"), - ], - [ - new URL("https://deno.land/std/assert/mod.ts?foo=bar"), - new URL("https://deno.land/std/assert"), - ], - [ - new URL("https://deno.land/std/assert/mod.ts#header"), - new URL("https://deno.land/std/assert"), - ], - [ - new URL("https://deno.land///"), - new URL("https://deno.land"), - ], -] as const; - -Deno.test("dirname()", function () { - for (const [testUrl, expected] of TESTSUITE) { - assertEquals(url.dirname(testUrl), expected); - } -}); diff --git a/url/extname.ts b/url/extname.ts deleted file mode 100755 index 09cd7f305ca1..000000000000 --- a/url/extname.ts +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -import { extname as posixExtname } from "@std/path/posix/extname"; -import { strip } from "./_strip.ts"; - -/** - * Returns the file extension of a given URL or string with leading period. - * - * The extension is sourced from the path portion of the URL. If there is no - * extension, an empty string is returned. URL queries and hashes are ignored. - * - * @param url The URL from which to extract the extension. - * @returns The extension of the URL. - * - * @example Usage - * ```ts - * import { extname } from "@std/url/extname"; - * import { assertEquals } from "@std/assert"; - * - * assertEquals(extname("https://deno.land/std/path/mod.ts"), ".ts"); - * assertEquals(extname("https://deno.land/std/path/mod"), ""); - * assertEquals(extname("https://deno.land/std/path/mod.ts?a=b"), ".ts"); - * assertEquals(extname("https://deno.land/"), ""); - * ``` - * - * @deprecated Use - * {@linkcode https://jsr.io/@std/path/doc/posix/~/extname | @std/path/posix/extname} - * instead (examples included). `@std/url` will be removed in the future. - */ -export function extname(url: string | URL): string { - url = new URL(url); - strip(url); - return posixExtname(url.pathname); -} diff --git a/url/extname_test.ts b/url/extname_test.ts deleted file mode 100755 index e1925b59ca5a..000000000000 --- a/url/extname_test.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -import { assertEquals } from "@std/assert"; -import * as url from "./mod.ts"; - -const TESTSUITE = [ - ["https://deno.land/std/assert/mod.ts", ".ts"], - [new URL("https://deno.land/std/assert/mod.ts"), ".ts"], - [new URL("https://deno.land/std/assert/mod.ts?foo=bar"), ".ts"], - [new URL("https://deno.land/std/assert/mod.ts#header"), ".ts"], - [new URL("https://deno.land/std/assert/mod."), "."], - [new URL("https://deno.land/std/assert/mod"), ""], -] as const; - -Deno.test("extname()", function () { - for (const [testUrl, expected] of TESTSUITE) { - assertEquals(url.extname(testUrl), expected); - } -}); diff --git a/url/join.ts b/url/join.ts deleted file mode 100755 index fcb89a53a8c3..000000000000 --- a/url/join.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -import { join as posixJoin } from "@std/path/posix/join"; - -/** - * 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 Usage - * - * ```ts - * import { join } from "@std/url/join"; - * import { assertEquals } from "@std/assert"; - * - * assertEquals(join("https://deno.land/", "std", "path", "mod.ts").href, "https://deno.land/std/path/mod.ts"); - * assertEquals(join("https://deno.land", "//std", "path/", "/mod.ts").href, "https://deno.land/std/path/mod.ts"); - * ``` - * - * @deprecated Use - * {@linkcode https://jsr.io/@std/path/doc/posix/~/join | @std/path/posix/join} - * instead (examples included). `@std/url` will be removed in the future. - */ -export function join(url: string | URL, ...paths: string[]): URL { - url = new URL(url); - url.pathname = posixJoin(url.pathname, ...paths); - return url; -} diff --git a/url/join_test.ts b/url/join_test.ts deleted file mode 100755 index c23d784c79b8..000000000000 --- a/url/join_test.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -import { assertEquals } from "@std/assert"; -import * as url from "./mod.ts"; - -const TESTSUITE: [[string | URL, ...string[]], URL][] = [ - [ - ["https://deno.land", "std", "assert", "mod.ts"], - new URL("https://deno.land/std/assert/mod.ts"), - ], - [ - [new URL("https://deno.land"), "std", "assert", "mod.ts"], - new URL("https://deno.land/std/assert/mod.ts"), - ], - [ - [new URL("https:///deno.land//std//"), "/", "/assert/", "//mod.ts"], - new URL("https://deno.land/std/assert/mod.ts"), - ], - [ - ["https://deno.land///", "/"], - new URL("https://deno.land/"), - ], -]; - -Deno.test("join()", function () { - for (const [[testUrl, ...paths], expected] of TESTSUITE) { - assertEquals(url.join(testUrl, ...paths), expected); - } -}); diff --git a/url/mod.ts b/url/mod.ts deleted file mode 100755 index 407c2f80c1ce..000000000000 --- a/url/mod.ts +++ /dev/null @@ -1,34 +0,0 @@ -// 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. - * - * ```ts - * import { basename, join, normalize } from "@std/url"; - * import { assertEquals } from "@std/assert"; - * - * const url = new URL("https:///deno.land///std//assert//.//mod.ts"); - * const normalizedUrl = normalize(url); - * - * assertEquals(normalizedUrl.href, "https://deno.land/std/assert/mod.ts"); - * assertEquals(basename(normalizedUrl), "mod.ts"); - * - * const joinedUrl = join(normalizedUrl, "..", "..", "async", "retry.ts"); - * - * assertEquals(joinedUrl.href, "https://deno.land/std/async/retry.ts"); - * ``` - * - * @deprecated Use functions from - * {@linkcode https://jsr.io/@std/path/doc/posix/~ | @std/path/posix} - * instead (examples included). `@std/url` will be removed in the future. - * - * @module - */ - -export * from "./basename.ts"; -export * from "./dirname.ts"; -export * from "./extname.ts"; -export * from "./join.ts"; -export * from "./normalize.ts"; diff --git a/url/normalize.ts b/url/normalize.ts deleted file mode 100755 index b9818bfc5630..000000000000 --- a/url/normalize.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. - -import { normalize as posixNormalize } from "@std/path/posix/normalize"; - -/** - * Normalizes the URL or URL string, resolving `..` and `.` segments. Multiple - * sequential `/`s are resolved into a single `/`. - * - * @param url URL to be normalized. - * @returns Normalized URL. - * - * @example Usage - * - * ```ts - * import { normalize } from "@std/url/normalize"; - * import { assertEquals } from "@std/assert"; - * - * assertEquals(normalize("https:///deno.land///std//assert//.//mod.ts").href, "https://deno.land/std/assert/mod.ts"); - * assertEquals(normalize("https://deno.land/std/assert/../async/retry.ts").href, "https://deno.land/std/async/retry.ts"); - * ``` - * - * @deprecated Use - * {@linkcode https://jsr.io/@std/path/doc/posix/~/normalize | @std/path/posix/normalize} - * instead (examples included). `@std/url` will be removed in the future. - */ -export function normalize(url: string | URL): URL { - url = new URL(url); - url.pathname = posixNormalize(url.pathname); - return url; -} diff --git a/url/normalize_test.ts b/url/normalize_test.ts deleted file mode 100755 index 65b6ebab2fe9..000000000000 --- a/url/normalize_test.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -import { assertEquals } from "@std/assert"; -import * as url from "./mod.ts"; - -const TESTSUITE = [ - [ - "https:///deno.land///std//assert////mod.ts", - new URL("https://deno.land/std/assert/mod.ts"), - ], - [ - "https://deno.land///std//assert////mod.ts?foo=bar", - new URL("https://deno.land/std/assert/mod.ts?foo=bar"), - ], - [ - "https://deno.land///std//assert////mod.ts#header", - new URL("https://deno.land/std/assert/mod.ts#header"), - ], - [ - "https:///deno.land/std/assert/mod.ts/..", - new URL("https://deno.land/std/assert/"), - ], - [ - new URL("https://deno.land/std/assert/../async/retry.ts/"), - new URL("https://deno.land/std/async/retry.ts/"), - ], - [ - "https:/deno.land//..", - new URL("https://deno.land"), - ], -] as const; - -Deno.test("normalize()", function () { - for (const [testUrl, expected] of TESTSUITE) { - assertEquals(url.normalize(testUrl), expected); - } -});