fix(service-worker): use correct names when listing `CacheDatabase` tables (#42622)
`CacheDatabase` uses the un-prefixed table names to interact with database tables. However, the `list()` method returns the raw, prefixed table names (which are not useful, since they cannot be used to open/delete a table). This commit fixes this by removing the prefix from the cache names returned by the `list()` method. NOTE: This method is currently not used anywhere, so this change does not affect the ServiceWorker behavior. PR Close #42622
This commit is contained in:
parent
53fe557da7
commit
7507ed2e54
|
@ -31,7 +31,10 @@ export class CacheDatabase implements Database {
|
||||||
const prefix = `${this.cacheNamePrefix}:`;
|
const prefix = `${this.cacheNamePrefix}:`;
|
||||||
const allCacheNames = await this.scope.caches.keys();
|
const allCacheNames = await this.scope.caches.keys();
|
||||||
const dbCacheNames = allCacheNames.filter(name => name.startsWith(prefix));
|
const dbCacheNames = allCacheNames.filter(name => name.startsWith(prefix));
|
||||||
return dbCacheNames;
|
|
||||||
|
// Return the un-prefixed table names, so they can be used with other `CacheDatabase` methods
|
||||||
|
// (for example, for opening/deleting a table).
|
||||||
|
return dbCacheNames.map(name => name.slice(prefix.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
async open(name: string, cacheQueryOptions?: CacheQueryOptions): Promise<Table> {
|
async open(name: string, cacheQueryOptions?: CacheQueryOptions): Promise<Table> {
|
||||||
|
|
Loading…
Reference in New Issue