mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Reorder the URLPatternResult and URLPatternComponentResult dictionary templates, together with their value arrays, to follow the lexicographical member order required by WebIDL. Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/64733 Fixes: https://github.com/nodejs/node/issues/64732 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
const { URLPattern } = require('url');
|
|
|
|
// Verify that if an error is thrown while accessing any of the
|
|
// init options, the error is appropriately propagated.
|
|
assert.throws(() => {
|
|
new URLPattern({
|
|
get protocol() {
|
|
throw new Error('boom');
|
|
}
|
|
});
|
|
}, {
|
|
message: 'boom',
|
|
});
|
|
|
|
// Verify that if an error is thrown while accessing the ignoreCase
|
|
// option, the error is appropriately propagated.
|
|
assert.throws(() => {
|
|
new URLPattern({}, { get ignoreCase() {
|
|
throw new Error('boom');
|
|
} });
|
|
}, {
|
|
message: 'boom'
|
|
});
|
|
|
|
{
|
|
const result = new URLPattern({ pathname: '/:value' })
|
|
.exec('https://example.com/test');
|
|
|
|
assert.deepStrictEqual(Object.keys(result), [
|
|
'hash',
|
|
'hostname',
|
|
'inputs',
|
|
'password',
|
|
'pathname',
|
|
'port',
|
|
'protocol',
|
|
'search',
|
|
'username',
|
|
]);
|
|
assert.deepStrictEqual(Object.keys(result.pathname), [
|
|
'groups',
|
|
'input',
|
|
]);
|
|
assert.strictEqual(result.hostname.input, 'example.com');
|
|
assert.strictEqual(result.pathname.input, '/test');
|
|
assert.strictEqual(result.pathname.groups.value, 'test');
|
|
}
|