@@ -91,11 +91,6 @@ const {
91
91
updateUrl,
92
92
} = internalBinding ( 'url' ) ;
93
93
94
- const {
95
- storeDataObject,
96
- revokeDataObject,
97
- } = internalBinding ( 'blob' ) ;
98
-
99
94
const FORWARD_SLASH = / \/ / g;
100
95
101
96
const context = Symbol ( 'context' ) ;
@@ -718,8 +713,33 @@ class URL {
718
713
toJSON ( ) {
719
714
return this . #context. href ;
720
715
}
716
+ }
717
+
718
+ ObjectDefineProperties ( URL . prototype , {
719
+ [ SymbolToStringTag ] : { __proto__ : null , configurable : true , value : 'URL' } ,
720
+ toString : kEnumerableProperty ,
721
+ href : kEnumerableProperty ,
722
+ origin : kEnumerableProperty ,
723
+ protocol : kEnumerableProperty ,
724
+ username : kEnumerableProperty ,
725
+ password : kEnumerableProperty ,
726
+ host : kEnumerableProperty ,
727
+ hostname : kEnumerableProperty ,
728
+ port : kEnumerableProperty ,
729
+ pathname : kEnumerableProperty ,
730
+ search : kEnumerableProperty ,
731
+ searchParams : kEnumerableProperty ,
732
+ hash : kEnumerableProperty ,
733
+ toJSON : kEnumerableProperty ,
734
+ } ) ;
735
+
736
+ function installObjectURLMethods ( ) {
737
+ const {
738
+ storeDataObject,
739
+ revokeDataObject,
740
+ } = internalBinding ( 'blob' ) ;
721
741
722
- static createObjectURL ( obj ) {
742
+ function createObjectURL ( obj ) {
723
743
const cryptoRandom = lazyCryptoRandom ( ) ;
724
744
if ( cryptoRandom === undefined )
725
745
throw new ERR_NO_CRYPTO ( ) ;
@@ -735,7 +755,7 @@ class URL {
735
755
return `blob:nodedata:${ id } ` ;
736
756
}
737
757
738
- static revokeObjectURL ( url ) {
758
+ function revokeObjectURL ( url ) {
739
759
url = `${ url } ` ;
740
760
try {
741
761
// TODO(@anonrig): Remove this try/catch by calling `parse` directly.
@@ -747,30 +767,24 @@ class URL {
747
767
// If there's an error, it's ignored.
748
768
}
749
769
}
750
- }
751
-
752
- ObjectDefineProperties ( URL . prototype , {
753
- [ SymbolToStringTag ] : { __proto__ : null , configurable : true , value : 'URL' } ,
754
- toString : kEnumerableProperty ,
755
- href : kEnumerableProperty ,
756
- origin : kEnumerableProperty ,
757
- protocol : kEnumerableProperty ,
758
- username : kEnumerableProperty ,
759
- password : kEnumerableProperty ,
760
- host : kEnumerableProperty ,
761
- hostname : kEnumerableProperty ,
762
- port : kEnumerableProperty ,
763
- pathname : kEnumerableProperty ,
764
- search : kEnumerableProperty ,
765
- searchParams : kEnumerableProperty ,
766
- hash : kEnumerableProperty ,
767
- toJSON : kEnumerableProperty ,
768
- } ) ;
769
770
770
- ObjectDefineProperties ( URL , {
771
- createObjectURL : kEnumerableProperty ,
772
- revokeObjectURL : kEnumerableProperty ,
773
- } ) ;
771
+ ObjectDefineProperties ( URL , {
772
+ createObjectURL : {
773
+ __proto__ : null ,
774
+ configurable : true ,
775
+ writable : true ,
776
+ enumerable : true ,
777
+ value : createObjectURL ,
778
+ } ,
779
+ revokeObjectURL : {
780
+ __proto__ : null ,
781
+ configurable : true ,
782
+ writable : true ,
783
+ enumerable : true ,
784
+ value : revokeObjectURL ,
785
+ } ,
786
+ } ) ;
787
+ }
774
788
775
789
// application/x-www-form-urlencoded parser
776
790
// Ref: https://url.spec.whatwg.org/#concept-urlencoded-parser
@@ -1251,6 +1265,7 @@ module.exports = {
1251
1265
fileURLToPath,
1252
1266
pathToFileURL,
1253
1267
toPathIfFileURL,
1268
+ installObjectURLMethods,
1254
1269
URL ,
1255
1270
URLSearchParams,
1256
1271
domainToASCII,
0 commit comments