Skip to content

Commit d94dd46

Browse files
committed
chore: lint, add some one-liners to examples
1 parent b0228a1 commit d94dd46

File tree

7 files changed

+7
-1
lines changed

7 files changed

+7
-1
lines changed

files/en-us/web/api/urlpattern/hash/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This pattern matches any fragment that starts with `books/` and ends with an arb
2626
```js
2727
const pattern = new URLPattern("https://example.org#books/:id");
2828
console.log(pattern.hash); // 'books/:id'
29+
console.log(pattern.test("https://example.org#books/123")); // true
2930
```
3031

3132
## Specifications

files/en-us/web/api/urlpattern/hostname/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This pattern matches any hostname that is a direct subdomain of `example.org`.
2626
```js
2727
const pattern = new URLPattern("https://*.example.org");
2828
console.log(pattern.hostname); // '*.example.org'
29+
console.log(pattern.test("https://horses.example.org")); // true
2930
```
3031

3132
## Specifications

files/en-us/web/api/urlpattern/password/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This pattern matches the passwords `correct-horse-battery` and `correct-horse-ba
2626
```js
2727
const pattern = new URLPattern({ password: "correct-horse-battery{-staple}?" });
2828
console.log(pattern.password); // 'correct-horse-battery{-staple}?'
29+
console.log(pattern.test("https://user:[email protected]")); // true
2930
```
3031

3132
## Specifications

files/en-us/web/api/urlpattern/pathname/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This pattern matches any URL that starts with `/books/`, followed by an integer.
2626
```js
2727
const pattern = new URLPattern({ pathname: "/books/:id(\\d)" });
2828
console.log(pattern.pathname); // "/books/:id(\\d)"
29+
console.log(pattern.test("https://example.com/books/8")); // true
2930
```
3031

3132
## Specifications

files/en-us/web/api/urlpattern/port/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ browser-compat: api.URLPattern.port
1010

1111
The **`port`** read-only property of the {{domxref("URLPattern")}} interface is a string containing the [pattern](/en-US/docs/Web/API/URL_Pattern_API#pattern_syntax) used to match the port part of a URL.
1212

13-
This is the [normalized value](/en-US/docs/Web/API/URL_Pattern_API#pattern_normalization) of the port pattern passed to the [constructor](/en-US/docs/Web/API/URLPattern/URLPattern), or an [inherited value from a `baseURL`](/en-US/docs/Web/API/URLPattern/URLPattern#inheritance_from_a_baseurl) passed to the constructor, or the default value ("*"), which matches any port.
13+
This is the [normalized value](/en-US/docs/Web/API/URL_Pattern_API#pattern_normalization) of the port pattern passed to the [constructor](/en-US/docs/Web/API/URLPattern/URLPattern), or an [inherited value from a `baseURL`](/en-US/docs/Web/API/URLPattern/URLPattern#inheritance_from_a_baseurl) passed to the constructor, or the default value (`"*"`), which matches any port.
1414

1515
Note that it may also be set implicitly to the empty string (`""`) if the pattern is specified using an [`url` or `baseURL` string and the port is not explicitly set](/en-US/docs/Web/API/URLPattern/URLPattern#hostname_in_url_or_baseurl_affects_default_port).
1616
This empty string matches against URLs that use the default port (`443`).

files/en-us/web/api/urlpattern/protocol/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This pattern matches any URL that has the `http` or `https` protocol.
2626
```js
2727
const pattern = new URLPattern({ protocol: "http{s}?" });
2828
console.log(pattern.protocol); // 'http{s}?'
29+
console.log(pattern.test("https://example.com/shoes?q=baby")); // true
2930
```
3031

3132
## Specifications

files/en-us/web/api/urlpattern/search/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const pattern = new URLPattern({
2828
search: "q=baby",
2929
});
3030
console.log(pattern.search); // "q=baby"
31+
console.log(pattern.test("https://example.com/shoes?q=baby")); // true
3132
```
3233

3334
## Specifications

0 commit comments

Comments
 (0)