Skip to content

Commit

Permalink
url: expose urlpattern as global
Browse files Browse the repository at this point in the history
PR-URL: nodejs#56950
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
JonasBa authored Feb 9, 2025
1 parent 6088183 commit d1f8ccb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions doc/api/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,16 @@ added: v10.0.0

The WHATWG `URL` class. See the [`URL`][] section.

## `URLPattern`

<!-- YAML
added: REPLACEME
-->

<!-- type=global -->

The WHATWG `URLPattern` class. See the [`URLPattern`][] section.

## `URLSearchParams`

<!-- YAML
Expand Down Expand Up @@ -1262,6 +1272,7 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
[`TextEncoder`]: util.md#class-utiltextencoder
[`TransformStreamDefaultController`]: webstreams.md#class-transformstreamdefaultcontroller
[`TransformStream`]: webstreams.md#class-transformstream
[`URLPattern`]: url.md#class-urlpattern
[`URLSearchParams`]: url.md#class-urlsearchparams
[`URL`]: url.md#class-url
[`WebSocket`]: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
Expand Down
4 changes: 3 additions & 1 deletion lib/internal/bootstrap/web/exposed-window-or-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {
defineLazyProperties,
defineReplaceableLazyAttribute,
exposeLazyInterfaces,
exposeInterface,
} = require('internal/util');

const {
Expand Down Expand Up @@ -63,8 +64,9 @@ exposeLazyInterfaces(globalThis, 'perf_hooks', [
defineReplaceableLazyAttribute(globalThis, 'perf_hooks', ['performance']);

// https://w3c.github.io/FileAPI/#creating-revoking
const { installObjectURLMethods } = require('internal/url');
const { installObjectURLMethods, URLPattern } = require('internal/url');
installObjectURLMethods();
exposeInterface(globalThis, 'URLPattern', URLPattern);

let fetchImpl;
// https://fetch.spec.whatwg.org/#fetch-method
Expand Down
2 changes: 0 additions & 2 deletions test/wpt/test-urlpattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ const { WPTRunner } = require('../common/wpt');
const runner = new WPTRunner('urlpattern');

runner.pretendGlobalThisAs('Window');
// TODO(@anonrig): Remove this once URLPattern is global.
runner.setInitScript(`global.URLPattern = require('node:url').URLPattern;`);
runner.runJsTests();

0 comments on commit d1f8ccb

Please sign in to comment.