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 d6fd86b
Show file tree
Hide file tree
Showing 27 changed files with 10,736 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
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 d6fd86b

Please sign in to comment.