From 58d8b2e98dbcf44e2282fccd1e50cc9b717edfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Mon, 13 Mar 2023 15:26:58 +0100 Subject: [PATCH] docs(ext): Update docs for URLPattern to make all examples work (#17870) --- ext/url/lib.deno_url.d.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ext/url/lib.deno_url.d.ts b/ext/url/lib.deno_url.d.ts index 8d9404bc62..329f5bf551 100644 --- a/ext/url/lib.deno_url.d.ts +++ b/ext/url/lib.deno_url.d.ts @@ -236,7 +236,7 @@ declare interface URLPatternResult { * ```ts * // Specify the pattern as structured data. * const pattern = new URLPattern({ pathname: "/users/:user" }); - * const match = pattern.exec("/users/joe"); + * const match = pattern.exec("https://blog.example.com/users/joe"); * console.log(match.pathname.groups.user); // joe * ``` * @@ -249,9 +249,9 @@ declare interface URLPatternResult { * * ```ts * // Specify a relative string pattern with a base URL. - * const pattern = new URLPattern("/:article", "https://blog.example.com"); - * console.log(pattern.test("https://blog.example.com/article")); // true - * console.log(pattern.test("https://blog.example.com/article/123")); // false + * const pattern = new URLPattern("/article/:id", "https://blog.example.com"); + * console.log(pattern.test("https://blog.example.com/article")); // false + * console.log(pattern.test("https://blog.example.com/article/123")); // true * ``` * * @category Web APIs @@ -262,13 +262,14 @@ declare class URLPattern { /** * Test if the given input matches the stored pattern. * - * The input can either be provided as a url string (with an optional base), - * or as individual components in the form of an object. + * The input can either be provided as an absolute URL string with an optional base, + * relative URL string with a required base, or as individual components + * in the form of an `URLPatternInit` object. * * ```ts * const pattern = new URLPattern("https://example.com/books/:id"); * - * // Test a url string. + * // Test an absolute url string. * console.log(pattern.test("https://example.com/books/123")); // true * * // Test a relative url with a base. @@ -283,13 +284,14 @@ declare class URLPattern { /** * Match the given input against the stored pattern. * - * The input can either be provided as a url string (with an optional base), - * or as individual components in the form of an object. + * The input can either be provided as an absolute URL string with an optional base, + * relative URL string with a required base, or as individual components + * in the form of an `URLPatternInit` object. * * ```ts * const pattern = new URLPattern("https://example.com/books/:id"); * - * // Match a url string. + * // Match an absolute url string. * let match = pattern.exec("https://example.com/books/123"); * console.log(match.pathname.groups.id); // 123 *