From 24611bab2990434c681028619cfd6a82f4baf718 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 25 Feb 2015 16:51:04 -0500 Subject: [PATCH] code review --- src/js/storage.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/js/storage.js b/src/js/storage.js index 51ed91c0e..f3d358966 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -136,6 +136,15 @@ var availableLists = {}; var relocationMap = {}; + var fixLocation = function(location) { + // https://github.com/gorhill/uBlock/issues/418 + // We now support built-in external filter lists + if ( /^https?:/.test(location) === false ) { + location = 'assets/thirdparties/' + location; + } + return location; + }; + // selected lists var onSelectedListsLoaded = function(store) { var µb = µBlock; @@ -185,16 +194,10 @@ continue; } entry = locations[location]; - // https://github.com/gorhill/uBlock/issues/418 - // We now support built-in external filter lists - if ( /^https?:/.test(location) === false ) { - location = 'assets/thirdparties/' + location; - } + location = fixLocation(location); // Migrate obsolete location to new location, if any if ( typeof entry.oldLocation === 'string' ) { - if ( /^https?:/.test(entry.oldLocation) === false ) { - entry.oldLocation = 'assets/thirdparties/' + entry.oldLocation; - } + entry.oldLocation = fixLocation(entry.oldLocation); relocationMap[entry.oldLocation] = location; } availableLists[location] = entry;