mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
docs(ext): Update docs for URLPattern to make all examples work (#17870)
This commit is contained in:
parent
11f225ef7d
commit
58d8b2e98d
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
|
||||
* // 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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue