@@ -91,11 +91,6 @@ const {
9191 updateUrl,
9292} = internalBinding ( 'url' ) ;
9393
94- const {
95- storeDataObject,
96- revokeDataObject,
97- } = internalBinding ( 'blob' ) ;
98-
9994const FORWARD_SLASH = / \/ / g;
10095
10196const context = Symbol ( 'context' ) ;
@@ -760,8 +755,33 @@ class URL {
760755 throw new ERR_INVALID_THIS ( 'URL' ) ;
761756 return this [ context ] . href ;
762757 }
758+ }
759+
760+ ObjectDefineProperties ( URL . prototype , {
761+ [ SymbolToStringTag ] : { __proto__ : null , configurable : true , value : 'URL' } ,
762+ toString : kEnumerableProperty ,
763+ href : kEnumerableProperty ,
764+ origin : kEnumerableProperty ,
765+ protocol : kEnumerableProperty ,
766+ username : kEnumerableProperty ,
767+ password : kEnumerableProperty ,
768+ host : kEnumerableProperty ,
769+ hostname : kEnumerableProperty ,
770+ port : kEnumerableProperty ,
771+ pathname : kEnumerableProperty ,
772+ search : kEnumerableProperty ,
773+ searchParams : kEnumerableProperty ,
774+ hash : kEnumerableProperty ,
775+ toJSON : kEnumerableProperty ,
776+ } ) ;
777+
778+ function installObjectURLMethods ( ) {
779+ const {
780+ storeDataObject,
781+ revokeDataObject,
782+ } = internalBinding ( 'blob' ) ;
763783
764- static createObjectURL ( obj ) {
784+ function createObjectURL ( obj ) {
765785 const cryptoRandom = lazyCryptoRandom ( ) ;
766786 if ( cryptoRandom === undefined )
767787 throw new ERR_NO_CRYPTO ( ) ;
@@ -777,7 +797,7 @@ class URL {
777797 return `blob:nodedata:${ id } ` ;
778798 }
779799
780- static revokeObjectURL ( url ) {
800+ function revokeObjectURL ( url ) {
781801 url = `${ url } ` ;
782802 try {
783803 // TODO(@anonrig): Remove this try/catch by calling `parse` directly.
@@ -789,30 +809,24 @@ class URL {
789809 // If there's an error, it's ignored.
790810 }
791811 }
792- }
793-
794- ObjectDefineProperties ( URL . prototype , {
795- [ SymbolToStringTag ] : { __proto__ : null , configurable : true , value : 'URL' } ,
796- toString : kEnumerableProperty ,
797- href : kEnumerableProperty ,
798- origin : kEnumerableProperty ,
799- protocol : kEnumerableProperty ,
800- username : kEnumerableProperty ,
801- password : kEnumerableProperty ,
802- host : kEnumerableProperty ,
803- hostname : kEnumerableProperty ,
804- port : kEnumerableProperty ,
805- pathname : kEnumerableProperty ,
806- search : kEnumerableProperty ,
807- searchParams : kEnumerableProperty ,
808- hash : kEnumerableProperty ,
809- toJSON : kEnumerableProperty ,
810- } ) ;
811812
812- ObjectDefineProperties ( URL , {
813- createObjectURL : kEnumerableProperty ,
814- revokeObjectURL : kEnumerableProperty ,
815- } ) ;
813+ ObjectDefineProperties ( URL , {
814+ createObjectURL : {
815+ __proto__ : null ,
816+ configurable : true ,
817+ writable : true ,
818+ enumerable : true ,
819+ value : createObjectURL ,
820+ } ,
821+ revokeObjectURL : {
822+ __proto__ : null ,
823+ configurable : true ,
824+ writable : true ,
825+ enumerable : true ,
826+ value : revokeObjectURL ,
827+ } ,
828+ } ) ;
829+ }
816830
817831// application/x-www-form-urlencoded parser
818832// Ref: https://url.spec.whatwg.org/#concept-urlencoded-parser
@@ -1297,6 +1311,7 @@ module.exports = {
12971311 fileURLToPath,
12981312 pathToFileURL,
12991313 toPathIfFileURL,
1314+ installObjectURLMethods,
13001315 isURLInstance,
13011316 URL ,
13021317 URLSearchParams,
0 commit comments