Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

// Not in setters_tests.json since lone surrogates are not portable JSON.
[{
property: 'pathname',
newValue: '\uDC01\uD802a',
expected: {
pathname: '/%EF%BF%BD%EF%BF%BDa'
}
},
{
property: 'search',
newValue: '\uDC01\uD802a',
expected: {
search: '?%EF%BF%BD%EF%BF%BDa'
}
},
{
property: 'hash',
newValue: '\uDC01\uD802a',
expected: {
hash: '#%EF%BF%BD%EF%BF%BDa'
}
},
{
property: 'host',
newValue: 'exa\uDC01\uD802mple.com',
expected: {href: 'http://example.net/', host: 'example.net'}
},
{
property: 'hostname',
newValue: 'exa\uDC01\uD802mple.com',
expected: {href: 'http://example.net/', hostname: 'example.net'}
}].forEach(({property, newValue, expected}) => {
test(() => {
const url = new URL('http://example.net/');
url[property] = newValue;
for (const [key, value] of Object.entries(expected)) {
assert_equals(url[key], value, key);
}
}, `Setting ${property} to a value with lone surrogates`);
});