@@ -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' ) ;
@@ -760,8 +755,33 @@ class URL {
760
755
throw new ERR_INVALID_THIS ( 'URL' ) ;
761
756
return this [ context ] . href ;
762
757
}
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' ) ;
763
783
764
- static createObjectURL ( obj ) {
784
+ function createObjectURL ( obj ) {
765
785
const cryptoRandom = lazyCryptoRandom ( ) ;
766
786
if ( cryptoRandom === undefined )
767
787
throw new ERR_NO_CRYPTO ( ) ;
@@ -777,7 +797,7 @@ class URL {
777
797
return `blob:nodedata:${ id } ` ;
778
798
}
779
799
780
- static revokeObjectURL ( url ) {
800
+ function revokeObjectURL ( url ) {
781
801
url = `${ url } ` ;
782
802
try {
783
803
// TODO(@anonrig): Remove this try/catch by calling `parse` directly.
@@ -789,30 +809,24 @@ class URL {
789
809
// If there's an error, it's ignored.
790
810
}
791
811
}
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
- } ) ;
811
812
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
+ }
816
830
817
831
// application/x-www-form-urlencoded parser
818
832
// Ref: https://url.spec.whatwg.org/#concept-urlencoded-parser
@@ -1297,6 +1311,7 @@ module.exports = {
1297
1311
fileURLToPath,
1298
1312
pathToFileURL,
1299
1313
toPathIfFileURL,
1314
+ installObjectURLMethods,
1300
1315
isURLInstance,
1301
1316
URL ,
1302
1317
URLSearchParams,
0 commit comments