From 3d2c4e28951d506ca36032f3fa9da2f7b619712e Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Fri, 4 Sep 2026 19:44:21 -0400 Subject: [PATCH] doc: fix URLPattern.exec() example output order The two `urlPattern.exec()` examples list the result properties in alphabetical order with JSON-style quoting, which is not what `console.log()` prints. Since the result properties are created in WebIDL order, the output starts with `inputs` followed by the components from `protocol` to `hash`, and each component lists `input` before `groups`. Update both examples to the actual output. Refs: https://github.com/nodejs/node/pull/64733 --- doc/api/url.md | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index 7759c03a15e7..5f1ee59bbc19 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -737,18 +737,16 @@ against a pattern. const myPattern = new URLPattern('https://nodejs.org/docs/latest/api/*.html'); console.log(myPattern.exec('https://nodejs.org/docs/latest/api/dns.html')); // Prints: -// { -// "hash": { "groups": { "0": "" }, "input": "" }, -// "hostname": { "groups": {}, "input": "nodejs.org" }, -// "inputs": [ -// "https://nodejs.org/docs/latest/api/dns.html" -// ], -// "password": { "groups": { "0": "" }, "input": "" }, -// "pathname": { "groups": { "0": "dns" }, "input": "/docs/latest/api/dns.html" }, -// "port": { "groups": {}, "input": "" }, -// "protocol": { "groups": {}, "input": "https" }, -// "search": { "groups": { "0": "" }, "input": "" }, -// "username": { "groups": { "0": "" }, "input": "" } +// [Object: null prototype] { +// inputs: [ 'https://nodejs.org/docs/latest/api/dns.html' ], +// protocol: { input: 'https', groups: {} }, +// username: { input: '', groups: { '0': '' } }, +// password: { input: '', groups: { '0': '' } }, +// hostname: { input: 'nodejs.org', groups: {} }, +// port: { input: '', groups: {} }, +// pathname: { input: '/docs/latest/api/dns.html', groups: { '0': 'dns' } }, +// search: { input: '', groups: { '0': '' } }, +// hash: { input: '', groups: { '0': '' } } // } console.log(myPattern.test('https://nodejs.org/docs/latest/api/dns.html')); @@ -811,18 +809,16 @@ matched input and matched groups. const myPattern = new URLPattern('https://nodejs.org/docs/latest/api/*.html'); console.log(myPattern.exec('https://nodejs.org/docs/latest/api/dns.html')); // Prints: -// { -// "hash": { "groups": { "0": "" }, "input": "" }, -// "hostname": { "groups": {}, "input": "nodejs.org" }, -// "inputs": [ -// "https://nodejs.org/docs/latest/api/dns.html" -// ], -// "password": { "groups": { "0": "" }, "input": "" }, -// "pathname": { "groups": { "0": "dns" }, "input": "/docs/latest/api/dns.html" }, -// "port": { "groups": {}, "input": "" }, -// "protocol": { "groups": {}, "input": "https" }, -// "search": { "groups": { "0": "" }, "input": "" }, -// "username": { "groups": { "0": "" }, "input": "" } +// [Object: null prototype] { +// inputs: [ 'https://nodejs.org/docs/latest/api/dns.html' ], +// protocol: { input: 'https', groups: {} }, +// username: { input: '', groups: { '0': '' } }, +// password: { input: '', groups: { '0': '' } }, +// hostname: { input: 'nodejs.org', groups: {} }, +// port: { input: '', groups: {} }, +// pathname: { input: '/docs/latest/api/dns.html', groups: { '0': 'dns' } }, +// search: { input: '', groups: { '0': '' } }, +// hash: { input: '', groups: { '0': '' } } // } ```