url: expose urlpattern as global

PR-URL: https://github.com/nodejs/node/pull/56950
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
Jonas 2025-02-09 10:32:59 -05:00 committed by GitHub
parent 6088183906
commit d1f8ccb10d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -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
@ -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

View file

@ -19,6 +19,7 @@ const {
defineLazyProperties,
defineReplaceableLazyAttribute,
exposeLazyInterfaces,
exposeInterface,
} = require('internal/util');
const {
@ -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

View file

@ -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();