Version
latest main branch
Platform
Subsystem
url
What steps will reproduce the bug?
const { URLPattern } = require('node:url');
// Member access order
const accessed = [];
new URLPattern(new Proxy({}, {
get(target, property, receiver) {
accessed.push(property);
return Reflect.get(target, property, receiver);
},
}));
console.log(accessed);
// Absent members in URLPatternResult.inputs
const pattern = new URLPattern({ pathname: '/x' });
const input = pattern.exec({ pathname: '/x' }).inputs[0];
console.log(Object.keys(input));
console.log('protocol' in input);
console.log({ ...input });
How often does it reproduce? Is there a required condition?
Every
What is the expected behavior? Why is that the expected behavior?
WebIDL dictionary members should be accessed in lexicographical order:
[
'baseURL',
'hash',
'hostname',
'password',
'pathname',
'port',
'protocol',
'search',
'username',
]
The echoed dictionary should contain only members present after WebIDL conversion:
Object.keys(input);
// ['pathname']
'protocol' in input;
// false
{ ...input };
// { pathname: '/x' }
An optional member explicitly set to undefined should also be treated as absent.
The member access-order difference affects the URLPattern constructor, exec(), and test(). The result-shape
difference is observable through URLPatternResult.inputs.
What do you see instead?
The members are accessed in the following order:
[
'protocol',
'username',
'password',
'hostname',
'port',
'pathname',
'search',
'hash',
'baseURL',
]
The echoed input exposes all dictionary members:
Object.keys(input);
// [
// 'protocol',
// 'username',
// 'password',
// 'hostname',
// 'search',
// 'hash',
// 'baseURL',
// ]
'protocol' in input;
// true
Absent members are enumerable own properties whose values are undefined.
Additional information
Refs: https://urlpattern.spec.whatwg.org/#url-pattern-match
Refs: https://webidl.spec.whatwg.org/#es-dictionary)
Refs: https://webidl.spec.whatwg.org/#idl-dictionaries
Refs: https://webidl.spec.whatwg.org/#es-dictionary)
Version
latest main branch
Platform
Subsystem
url
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Every
What is the expected behavior? Why is that the expected behavior?
WebIDL dictionary members should be accessed in lexicographical order:
The echoed dictionary should contain only members present after WebIDL conversion:
An optional member explicitly set to undefined should also be treated as absent.
The member access-order difference affects the URLPattern constructor, exec(), and test(). The result-shape
difference is observable through URLPatternResult.inputs.
What do you see instead?
The members are accessed in the following order:
The echoed input exposes all dictionary members:
Absent members are enumerable own properties whose values are undefined.
Additional information
Refs: https://urlpattern.spec.whatwg.org/#url-pattern-match
Refs: https://webidl.spec.whatwg.org/#es-dictionary)
Refs: https://webidl.spec.whatwg.org/#idl-dictionaries
Refs: https://webidl.spec.whatwg.org/#es-dictionary)