MCPcopy Index your code
hub / github.com/nodejs/node / installObjectURLMethods

Function installObjectURLMethods

lib/internal/url.js:1212–1255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1210});
1211
1212function installObjectURLMethods() {
1213 const bindingBlob = internalBinding('blob');
1214
1215 function createObjectURL(obj) {
1216 const cryptoRandom = lazyCryptoRandom();
1217 if (cryptoRandom === undefined)
1218 throw new ERR_NO_CRYPTO();
1219
1220 const blob = lazyBlob();
1221 if (!blob.isBlob(obj))
1222 throw new ERR_INVALID_ARG_TYPE('obj', 'Blob', obj);
1223
1224 const id = cryptoRandom.randomUUID();
1225
1226 bindingBlob.storeDataObject(id, obj[blob.kHandle], obj.size, obj.type);
1227
1228 return `blob:nodedata:${id}`;
1229 }
1230
1231 function revokeObjectURL(url) {
1232 if (arguments.length === 0) {
1233 throw new ERR_MISSING_ARGS('url');
1234 }
1235
1236 bindingBlob.revokeObjectURL(`${url}`);
1237 }
1238
1239 ObjectDefineProperties(URL, {
1240 createObjectURL: {
1241 __proto__: null,
1242 configurable: true,
1243 writable: true,
1244 enumerable: true,
1245 value: createObjectURL,
1246 },
1247 revokeObjectURL: {
1248 __proto__: null,
1249 configurable: true,
1250 writable: true,
1251 enumerable: true,
1252 value: revokeObjectURL,
1253 },
1254 });
1255}
1256
1257// application/x-www-form-urlencoded parser
1258// Ref: https://url.spec.whatwg.org/#concept-urlencoded-parser

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected