Skip to content

url: URLPattern.exec() result properties are not created in WebIDL order #64732

Description

@Archkon

Version

latest main branch

Platform

7.1.4-arch1-1

Subsystem

url

What steps will reproduce the bug?

  const { URLPattern } = require('node:url');

  const pattern = new URLPattern({ pathname: '/:value' });
  const result = pattern.exec('https://example.com/test');

  console.log(Object.keys(result));
  console.log(Object.keys(result.pathname));
  console.log(JSON.stringify(result.pathname));

How often does it reproduce? Is there a required condition?

Every

What is the expected behavior? Why is that the expected behavior?

  [
    'hash',
    'hostname',
    'pathname',
    'port',
    'protocol',
    'search',
    'username'
  ]

  [ 'groups', 'input' ]

  '{"groups":{"value":"test"},"input":"/test"}'

What do you see instead?

  [
    'inputs',
    'protocol',
    'username',
    'password',
    'hostname',
    'port',
    'pathname',
    'search',
    'hash'
  ]

  [ 'input', 'groups' ]

  '{"input":"/test","groups":{"value":"test"}}'

Additional information

Although direct property access is unaffected, property creation order is observable through:

  Object.keys(result);
  Object.values(result);
  JSON.stringify(result);
  ({ ...result });

This makes Node.js behavior incompatible with browsers and WebIDL dictionary conversion semantics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions