|
|
@@ -35,6 +35,8 @@ const Cache = {
|
|
|
|
|
|
if ( this.enabled === false ) return;
|
|
|
|
|
|
+ if ( isBlobURL( key ) ) return;
|
|
|
+
|
|
|
// log( 'Cache', 'Adding key:', key );
|
|
|
|
|
|
this.files[ key ] = file;
|
|
|
@@ -52,6 +54,8 @@ const Cache = {
|
|
|
|
|
|
if ( this.enabled === false ) return;
|
|
|
|
|
|
+ if ( isBlobURL( key ) ) return;
|
|
|
+
|
|
|
// log( 'Cache', 'Checking key:', key );
|
|
|
|
|
|
return this.files[ key ];
|
|
|
@@ -83,5 +87,29 @@ const Cache = {
|
|
|
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * Returns true if the given cache key contains the blob: scheme.
|
|
|
+ *
|
|
|
+ * @private
|
|
|
+ * @param {string} key - The cache key.
|
|
|
+ * @return {boolean} Whether the given cache key contains the blob: scheme or not.
|
|
|
+ */
|
|
|
+function isBlobURL( key ) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ const urlString = key.slice( key.indexOf( ':' ) + 1 ); // remove type identifier
|
|
|
+
|
|
|
+ const url = new URL( urlString );
|
|
|
+ return url.protocol === 'blob:';
|
|
|
+
|
|
|
+ } catch ( e ) {
|
|
|
+
|
|
|
+ // If the string is not a valid URL, it throws an error
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
export { Cache };
|