File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ const Cache = {
3535
3636 if ( this . enabled === false ) return ;
3737
38+ if ( isBlobURL ( key ) ) return ;
39+
3840 // log( 'Cache', 'Adding key:', key );
3941
4042 this . files [ key ] = file ;
@@ -52,6 +54,8 @@ const Cache = {
5254
5355 if ( this . enabled === false ) return ;
5456
57+ if ( isBlobURL ( key ) ) return ;
58+
5559 // log( 'Cache', 'Checking key:', key );
5660
5761 return this . files [ key ] ;
@@ -83,5 +87,29 @@ const Cache = {
8387
8488} ;
8589
90+ /**
91+ * Returns true if the given cache key contains the blob: scheme.
92+ *
93+ * @private
94+ * @param {string } key - The cache key.
95+ * @return {boolean } Whether the given cache key contains the blob: scheme or not.
96+ */
97+ function isBlobURL ( key ) {
98+
99+ try {
100+
101+ const urlString = key . slice ( key . indexOf ( ':' ) + 1 ) ; // remove type identifier
102+
103+ const url = new URL ( urlString ) ;
104+ return url . protocol === 'blob:' ;
105+
106+ } catch ( e ) {
107+
108+ // If the string is not a valid URL, it throws an error
109+ return false ;
110+
111+ }
112+
113+ }
86114
87115export { Cache } ;
You can’t perform that action at this time.
0 commit comments