Fix idbStorage.keys()

Related commit:
https://github.com/gorhill/uBlock/commit/d4efaf020b
This commit is contained in:
Raymond Hill 2024-02-29 13:28:04 -05:00
parent d8544dc047
commit 801d6500b0
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 6 additions and 6 deletions

View File

@ -790,7 +790,7 @@ async function assetCacheRemove(pattern, options = {}) {
}
if ( options.janitor && pattern instanceof RegExp ) {
const re = new RegExp(
pattern.source.replace(/^\^/, 'cache\/'),
pattern.source.replace(/^\^/, '^cache\\/'),
pattern.flags
);
const keys = await cacheStorage.keys(re);

View File

@ -546,7 +546,7 @@ const idbStorage = (( ) => {
});
};
const getAllKeys = async function() {
const getAllKeys = async function(regex) {
const db = await getDb();
if ( db === null ) { return []; }
return new Promise(resolve => {
@ -562,6 +562,7 @@ const idbStorage = (( ) => {
req.onsuccess = ev => {
const cursor = ev.target && ev.target.result;
if ( !cursor ) { return; }
if ( regex && regex.test(cursor.key) === false ) { return; }
keys.push(cursor.key);
cursor.continue();
};
@ -685,8 +686,8 @@ const idbStorage = (( ) => {
return setEntries(bin);
},
keys() {
return getAllKeys();
keys(...args) {
return getAllKeys(...args);
},
remove(...args) {

View File

@ -232,8 +232,7 @@ const onUserSettingsReady = fetched => {
fetched.importedLists.length === 0 &&
fetched.externalLists !== ''
) {
fetched.importedLists =
fetched.externalLists.trim().split(/[\n\r]+/);
fetched.importedLists = fetched.externalLists.trim().split(/[\n\r]+/);
}
fromFetch(µb.userSettings, fetched);