Skip to content

Commit 276cf9a

Browse files
committed
src: implement whatwg's URLPattern spec
1 parent d780b90 commit 276cf9a

28 files changed

+10743
-1973
lines changed

deps/ada/ada.cpp

Lines changed: 4382 additions & 1693 deletions
Large diffs are not rendered by default.

deps/ada/ada.h

Lines changed: 1897 additions & 279 deletions
Large diffs are not rendered by default.

lib/internal/bootstrap/web/exposed-wildcard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ const config = internalBinding('config');
2323
exposeNamespace(globalThis, 'console',
2424
createGlobalConsole());
2525

26-
const { URL, URLSearchParams } = require('internal/url');
26+
const { URL, URLSearchParams, URLPattern } = require('internal/url');
2727
// https://url.spec.whatwg.org/#url
2828
exposeInterface(globalThis, 'URL', URL);
29+
// https://urlpattern.spec.whatwg.org/#urlpattern-class
30+
exposeInterface(globalThis, 'URLPattern', URLPattern);
2931
// https://url.spec.whatwg.org/#urlsearchparams
3032
exposeInterface(globalThis, 'URLSearchParams', URLSearchParams);
3133
exposeGetterAndSetter(globalThis,

lib/internal/url.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const {
3232
decodeURIComponent,
3333
} = primordials;
3434

35+
const { URLPattern } = internalBinding('url_pattern');
3536
const { inspect } = require('internal/util/inspect');
3637
const {
3738
encodeStr,
@@ -1571,6 +1572,7 @@ module.exports = {
15711572
toPathIfFileURL,
15721573
installObjectURLMethods,
15731574
URL,
1575+
URLPattern,
15741576
URLSearchParams,
15751577
URLParse: URL.parse,
15761578
domainToASCII,

lib/url.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const {
3030
decodeURIComponent,
3131
} = primordials;
3232

33+
const { URLPattern } = internalBinding('url_pattern');
3334
const { toASCII } = internalBinding('encoding_binding');
3435
const { encodeStr, hexTable } = require('internal/querystring');
3536
const querystring = require('querystring');
@@ -1029,6 +1030,7 @@ module.exports = {
10291030

10301031
// WHATWG API
10311032
URL,
1033+
URLPattern,
10321034
URLSearchParams,
10331035
domainToASCII,
10341036
domainToUnicode,

node.gyp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
'src/node_trace_events.cc',
147147
'src/node_types.cc',
148148
'src/node_url.cc',
149+
'src/node_url_pattern.cc',
149150
'src/node_util.cc',
150151
'src/node_v8.cc',
151152
'src/node_wasi.cc',
@@ -275,6 +276,7 @@
275276
'src/node_stat_watcher.h',
276277
'src/node_union_bytes.h',
277278
'src/node_url.h',
279+
'src/node_url_pattern.h',
278280
'src/node_version.h',
279281
'src/node_v8.h',
280282
'src/node_v8_platform-inl.h',

src/env_properties.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
V(async_ids_stack_string, "async_ids_stack") \
7979
V(attributes_string, "attributes") \
8080
V(base_string, "base") \
81+
V(base_url_string, "baseURL") \
8182
V(bits_string, "bits") \
8283
V(block_list_string, "blockList") \
8384
V(buffer_string, "buffer") \
@@ -175,13 +176,16 @@
175176
V(get_data_clone_error_string, "_getDataCloneError") \
176177
V(get_shared_array_buffer_id_string, "_getSharedArrayBufferId") \
177178
V(gid_string, "gid") \
179+
V(has_regexp_groups_string, "hasRegExpGroups") \
180+
V(hash_string, "hash") \
178181
V(h2_string, "h2") \
179182
V(handle_string, "handle") \
180183
V(hash_algorithm_string, "hashAlgorithm") \
181184
V(help_text_string, "helpText") \
182185
V(homedir_string, "homedir") \
183186
V(host_string, "host") \
184187
V(hostmaster_string, "hostmaster") \
188+
V(hostname_string, "hostname") \
185189
V(http_1_1_string, "http/1.1") \
186190
V(id_string, "id") \
187191
V(identity_string, "identity") \
@@ -276,6 +280,7 @@
276280
V(parse_error_string, "Parse Error") \
277281
V(password_string, "password") \
278282
V(path_string, "path") \
283+
V(pathname_string, "pathname") \
279284
V(pending_handle_string, "pendingHandle") \
280285
V(permission_string, "permission") \
281286
V(pid_string, "pid") \
@@ -291,6 +296,7 @@
291296
V(priority_string, "priority") \
292297
V(process_string, "process") \
293298
V(promise_string, "promise") \
299+
V(protocol_string, "protocol") \
294300
V(prototype_string, "prototype") \
295301
V(psk_string, "psk") \
296302
V(pubkey_string, "pubkey") \
@@ -318,6 +324,7 @@
318324
V(scheme_string, "scheme") \
319325
V(scopeid_string, "scopeid") \
320326
V(script_name_string, "scriptName") \
327+
V(search_string, "search") \
321328
V(serial_number_string, "serialNumber") \
322329
V(serial_string, "serial") \
323330
V(servername_string, "servername") \

src/node_binding.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "node_builtins.h"
55
#include "node_errors.h"
66
#include "node_external_reference.h"
7+
#include "node_url_pattern.h"
78
#include "util.h"
89

910
#include <string>
@@ -87,6 +88,7 @@
8788
V(types) \
8889
V(udp_wrap) \
8990
V(url) \
91+
V(url_pattern) \
9092
V(util) \
9193
V(uv) \
9294
V(v8) \

src/node_external_reference.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class ExternalReferenceRegistry {
180180
V(tty_wrap) \
181181
V(udp_wrap) \
182182
V(url) \
183+
V(url_pattern) \
183184
V(util) \
184185
V(pipe_wrap) \
185186
V(sea) \

0 commit comments

Comments
 (0)