node/lib/internal/inspector/network_resources.js
Shima Ryuhei d02831ef73
inspector: initial support for Network.loadNetworkResource
Fixes: https://github.com/nodejs/node/issues/57873
PR-URL: https://github.com/nodejs/node/pull/58077
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-08-04 12:25:23 +02:00

27 lines
820 B
JavaScript

'use strict';
const { getOptionValue } = require('internal/options');
const { validateString } = require('internal/validators');
const { putNetworkResource } = internalBinding('inspector');
/**
* Registers a resource for the inspector using the internal 'putNetworkResource' binding.
* @param {string} url - The URL of the resource.
* @param {string} data - The content of the resource to provide.
*/
function put(url, data) {
if (!getOptionValue('--experimental-inspector-network-resource')) {
process.emitWarning(
'The --experimental-inspector-network-resource option is not enabled. ' +
'Please enable it to use the putNetworkResource function');
return;
}
validateString(url, 'url');
validateString(data, 'data');
putNetworkResource(url, data);
}
module.exports = {
put,
};