mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
docs(ext): Update docs for URLPattern to make all examples work (#17870)
This commit is contained in:
parent
93e66dabcb
commit
f5943f248c
1 changed files with 12 additions and 10 deletions
22
ext/url/lib.deno_url.d.ts
vendored
22
ext/url/lib.deno_url.d.ts
vendored
|
@ -236,7 +236,7 @@ declare interface URLPatternResult {
|
||||||
* ```ts
|
* ```ts
|
||||||
* // Specify the pattern as structured data.
|
* // Specify the pattern as structured data.
|
||||||
* const pattern = new URLPattern({ pathname: "/users/:user" });
|
* 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
|
* console.log(match.pathname.groups.user); // joe
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
@ -249,9 +249,9 @@ declare interface URLPatternResult {
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* // Specify a relative string pattern with a base URL.
|
* // Specify a relative string pattern with a base URL.
|
||||||
* const pattern = new URLPattern("/:article", "https://blog.example.com");
|
* const pattern = new URLPattern("/article/:id", "https://blog.example.com");
|
||||||
* console.log(pattern.test("https://blog.example.com/article")); // true
|
* console.log(pattern.test("https://blog.example.com/article")); // false
|
||||||
* console.log(pattern.test("https://blog.example.com/article/123")); // false
|
* console.log(pattern.test("https://blog.example.com/article/123")); // true
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @category Web APIs
|
* @category Web APIs
|
||||||
|
@ -262,13 +262,14 @@ declare class URLPattern {
|
||||||
/**
|
/**
|
||||||
* Test if the given input matches the stored pattern.
|
* Test if the given input matches the stored pattern.
|
||||||
*
|
*
|
||||||
* The input can either be provided as a url string (with an optional base),
|
* The input can either be provided as an absolute URL string with an optional base,
|
||||||
* or as individual components in the form of an object.
|
* relative URL string with a required base, or as individual components
|
||||||
|
* in the form of an `URLPatternInit` object.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const pattern = new URLPattern("https://example.com/books/:id");
|
* 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
|
* console.log(pattern.test("https://example.com/books/123")); // true
|
||||||
*
|
*
|
||||||
* // Test a relative url with a base.
|
* // Test a relative url with a base.
|
||||||
|
@ -283,13 +284,14 @@ declare class URLPattern {
|
||||||
/**
|
/**
|
||||||
* Match the given input against the stored pattern.
|
* Match the given input against the stored pattern.
|
||||||
*
|
*
|
||||||
* The input can either be provided as a url string (with an optional base),
|
* The input can either be provided as an absolute URL string with an optional base,
|
||||||
* or as individual components in the form of an object.
|
* relative URL string with a required base, or as individual components
|
||||||
|
* in the form of an `URLPatternInit` object.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const pattern = new URLPattern("https://example.com/books/:id");
|
* 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");
|
* let match = pattern.exec("https://example.com/books/123");
|
||||||
* console.log(match.pathname.groups.id); // 123
|
* console.log(match.pathname.groups.id); // 123
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue