Skip to content

Commit

Permalink
src: implement whatwg's URLPattern spec
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Dec 22, 2024
1 parent d780b90 commit d3a020c
Show file tree
Hide file tree
Showing 28 changed files with 10,751 additions and 1,973 deletions.
6,075 changes: 4,382 additions & 1,693 deletions deps/ada/ada.cpp

Large diffs are not rendered by default.

2,176 changes: 1,897 additions & 279 deletions deps/ada/ada.h

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/internal/bootstrap/web/exposed-wildcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ const config = internalBinding('config');
exposeNamespace(globalThis, 'console',
createGlobalConsole());

const { URL, URLSearchParams } = require('internal/url');
const { URL, URLSearchParams, URLPattern } = require('internal/url');
// https://url.spec.whatwg.org/#url
exposeInterface(globalThis, 'URL', URL);
// https://urlpattern.spec.whatwg.org/#urlpattern-class
exposeInterface(globalThis, 'URLPattern', URLPattern);
// https://url.spec.whatwg.org/#urlsearchparams
exposeInterface(globalThis, 'URLSearchParams', URLSearchParams);
exposeGetterAndSetter(globalThis,
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const {
decodeURIComponent,
} = primordials;

const { URLPattern } = internalBinding('url_pattern');
const { inspect } = require('internal/util/inspect');
const {
encodeStr,
Expand Down Expand Up @@ -1571,6 +1572,7 @@ module.exports = {
toPathIfFileURL,
installObjectURLMethods,
URL,
URLPattern,
URLSearchParams,
URLParse: URL.parse,
domainToASCII,
Expand Down
2 changes: 2 additions & 0 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
decodeURIComponent,
} = primordials;

const { URLPattern } = internalBinding('url_pattern');
const { toASCII } = internalBinding('encoding_binding');
const { encodeStr, hexTable } = require('internal/querystring');
const querystring = require('querystring');
Expand Down Expand Up @@ -1029,6 +1030,7 @@ module.exports = {

// WHATWG API
URL,
URLPattern,
URLSearchParams,
domainToASCII,
domainToUnicode,
Expand Down
2 changes: 2 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
'src/node_trace_events.cc',
'src/node_types.cc',
'src/node_url.cc',
'src/node_url_pattern.cc',
'src/node_util.cc',
'src/node_v8.cc',
'src/node_wasi.cc',
Expand Down Expand Up @@ -275,6 +276,7 @@
'src/node_stat_watcher.h',
'src/node_union_bytes.h',
'src/node_url.h',
'src/node_url_pattern.h',
'src/node_version.h',
'src/node_v8.h',
'src/node_v8_platform-inl.h',
Expand Down
7 changes: 7 additions & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
V(async_ids_stack_string, "async_ids_stack") \
V(attributes_string, "attributes") \
V(base_string, "base") \
V(base_url_string, "baseURL") \
V(bits_string, "bits") \
V(block_list_string, "blockList") \
V(buffer_string, "buffer") \
Expand Down Expand Up @@ -175,13 +176,16 @@
V(get_data_clone_error_string, "_getDataCloneError") \
V(get_shared_array_buffer_id_string, "_getSharedArrayBufferId") \
V(gid_string, "gid") \
V(has_regexp_groups_string, "hasRegExpGroups") \
V(hash_string, "hash") \
V(h2_string, "h2") \
V(handle_string, "handle") \
V(hash_algorithm_string, "hashAlgorithm") \
V(help_text_string, "helpText") \
V(homedir_string, "homedir") \
V(host_string, "host") \
V(hostmaster_string, "hostmaster") \
V(hostname_string, "hostname") \
V(http_1_1_string, "http/1.1") \
V(id_string, "id") \
V(identity_string, "identity") \
Expand Down Expand Up @@ -276,6 +280,7 @@
V(parse_error_string, "Parse Error") \
V(password_string, "password") \
V(path_string, "path") \
V(pathname_string, "pathname") \
V(pending_handle_string, "pendingHandle") \
V(permission_string, "permission") \
V(pid_string, "pid") \
Expand All @@ -291,6 +296,7 @@
V(priority_string, "priority") \
V(process_string, "process") \
V(promise_string, "promise") \
V(protocol_string, "protocol") \
V(prototype_string, "prototype") \
V(psk_string, "psk") \
V(pubkey_string, "pubkey") \
Expand Down Expand Up @@ -318,6 +324,7 @@
V(scheme_string, "scheme") \
V(scopeid_string, "scopeid") \
V(script_name_string, "scriptName") \
V(search_string, "search") \
V(serial_number_string, "serialNumber") \
V(serial_string, "serial") \
V(servername_string, "servername") \
Expand Down
2 changes: 2 additions & 0 deletions src/node_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "node_builtins.h"
#include "node_errors.h"
#include "node_external_reference.h"
#include "node_url_pattern.h"
#include "util.h"

#include <string>
Expand Down Expand Up @@ -87,6 +88,7 @@
V(types) \
V(udp_wrap) \
V(url) \
V(url_pattern) \
V(util) \
V(uv) \
V(v8) \
Expand Down
1 change: 1 addition & 0 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class ExternalReferenceRegistry {
V(tty_wrap) \
V(udp_wrap) \
V(url) \
V(url_pattern) \
V(util) \
V(pipe_wrap) \
V(sea) \
Expand Down
Loading

0 comments on commit d3a020c

Please sign in to comment.