diff options
Diffstat (limited to 'cli/tsc/dts/lib.dom.extras.d.ts')
-rw-r--r-- | cli/tsc/dts/lib.dom.extras.d.ts | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/cli/tsc/dts/lib.dom.extras.d.ts b/cli/tsc/dts/lib.dom.extras.d.ts index 9116596a6..441eb9221 100644 --- a/cli/tsc/dts/lib.dom.extras.d.ts +++ b/cli/tsc/dts/lib.dom.extras.d.ts @@ -59,7 +59,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 * ``` * @@ -72,24 +72,23 @@ 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 * ``` */ -declare class URLPattern { - constructor(input: URLPatternInput, baseURL?: string); - +interface 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. @@ -104,13 +103,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 * @@ -143,6 +143,39 @@ declare class URLPattern { readonly hash: string; } +/** + * The URLPattern API provides a web platform primitive for matching URLs based + * on a convenient pattern syntax. + * + * The syntax is based on path-to-regexp. Wildcards, named capture groups, + * regular groups, and group modifiers are all supported. + * + * ```ts + * // Specify the pattern as structured data. + * const pattern = new URLPattern({ pathname: "/users/:user" }); + * const match = pattern.exec("https://blog.example.com/users/joe"); + * console.log(match.pathname.groups.user); // joe + * ``` + * + * ```ts + * // Specify a fully qualified string pattern. + * const pattern = new URLPattern("https://example.com/books/:id"); + * console.log(pattern.test("https://example.com/books/123")); // true + * console.log(pattern.test("https://deno.land/books/123")); // false + * ``` + * + * ```ts + * // Specify a relative string pattern with a base URL. + * 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 + * ``` + */ +declare var URLPattern: { + readonly prototype: URLPattern; + new (input: URLPatternInput, baseURL?: string): URLPattern; +}; + interface ErrorConstructor { /** See https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions. */ captureStackTrace(error: Object, constructor?: Function): void; |