node/test/parallel/test-urlpattern.js
James M Snell 35d199f27b src: make multiple improvements to node_url_pattern
* remove USE from node_url_pattern to handle error correctly
* simplify if block in node_url_pattern
* improve error handling in node_url_pattern
* fix error propagation on URLPattern init
* use ToV8Value where more convenient in node_url_pattern
* simplify URLPatternInit::ToJsObject by reducing boilerplate

PR-URL: https://github.com/nodejs/node/pull/56871
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-02-03 13:54:20 -08:00

29 lines
602 B
JavaScript

'use strict';
require('../common');
const { throws } = 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.
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.
throws(() => {
new URLPattern({}, { get ignoreCase() {
throw new Error('boom');
} });
}, {
message: 'boom'
});