BREAKING(url): remove @std/url (#5931)

This commit is contained in:
Asher Gomez 2024-09-10 19:22:37 +10:00 committed by GitHub
parent 9c36e5e246
commit fc0f55c00c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 0 additions and 386 deletions

View File

@ -73,7 +73,6 @@ type Mod =
| "text"
| "toml"
| "ulid"
| "url"
| "uuid"
| "webgpu"
| "yaml";
@ -117,7 +116,6 @@ const ENTRYPOINTS: Record<Mod, string[]> = {
text: ["mod.ts"],
toml: ["mod.ts"],
ulid: ["mod.ts"],
url: ["mod.ts"],
uuid: ["mod.ts"],
webgpu: ["mod.ts"],
yaml: ["mod.ts"],

View File

@ -75,7 +75,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",

View File

@ -86,7 +86,6 @@
"./text",
"./toml",
"./ulid",
"./url",
"./uuid",
"./webgpu",
"./yaml"

View File

@ -44,7 +44,6 @@
"@std/text": "jsr:@std/text@^1.0.5",
"@std/toml": "jsr:@std/toml@^1.0.1",
"@std/ulid": "jsr:@std/ulid@^1.0.0",
"@std/url": "jsr:@std/url@^0.225.1",
"@std/uuid": "jsr:@std/uuid@^1.0.3",
"@std/webgpu": "jsr:@std/webgpu@^0.224.7",
"@std/yaml": "jsr:@std/yaml@^1.0.5"

View File

@ -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 = "";
}

View File

@ -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/~/basename | @std/path/basename}
* instead. `@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);
}

View File

@ -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);
}
});

View File

@ -1,12 +0,0 @@
{
"name": "@std/url",
"version": "0.225.1",
"exports": {
".": "./mod.ts",
"./basename": "./basename.ts",
"./dirname": "./dirname.ts",
"./extname": "./extname.ts",
"./join": "./join.ts",
"./normalize": "./normalize.ts"
}
}

View File

@ -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/~/dirname | @std/path/dirname}
* instead. `@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;
}

View File

@ -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);
}
});

View File

@ -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/~/extname | @std/path/extname}
* instead. `@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);
}

View File

@ -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);
}
});

View File

@ -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/~/join | @std/path/join}
* instead. `@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;
}

View File

@ -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);
}
});

View File

@ -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";

View File

@ -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/~/normalize | @std/path/normalize}
* instead. `@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;
}

View File

@ -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);
}
});