diff --git a/config/default.js b/config/default.js index c3151bd..bd3ecad 100644 --- a/config/default.js +++ b/config/default.js @@ -37,6 +37,7 @@ const conf = { }, timeout: process.env.WTP_TIMEOUT || 30000, "locationSelector": { + "allowRegex": process.env.WTP_LS_ALLOW_REGEX || '_US_', "cacheTtl": process.env.WTP_LS_CACHE_TTL || 10, "updateTimeout": process.env.WTP_LS_UPDATE_TIMEOUT || 20, "defaultLocation": process.env.WTP_LS_DEFAULT_LOCATION || "IAD_US_01" diff --git a/wtp/apiCaller.js b/wtp/apiCaller.js index 4f1e41b..2894041 100644 --- a/wtp/apiCaller.js +++ b/wtp/apiCaller.js @@ -70,7 +70,7 @@ const runWtpTest = async (url, mobile, cb) => { height: config.get('wtp.viewportHeight'), custom: config.get('wtp.imageScript'), location: await locationSelector.getLocation() + ':Chrome.Native', // Native means no speed shaping in browser, full speed ahead - mobile: (mobile) ? 1 : 0, + mobile: (mobile) ? 1 : 0, fvonly: 1, // first view only timeline: 1 // workaround for WPT sometimes hanging on getComputedStyle() }, diff --git a/wtp/locationSelector.js b/wtp/locationSelector.js index 8325f67..07ec370 100644 --- a/wtp/locationSelector.js +++ b/wtp/locationSelector.js @@ -31,6 +31,7 @@ class LocationSelector { if (!LocationSelector.instance) { this.cachedAllLocations = []; this.location = config.get('wtp.locationSelector.defaultLocation'); + this.allowRegex = new RegExp(config.get('wtp.locationSelector.allowRegex')); this.lastUpdated = null; this.mutex = withTimeout(new Mutex(), config.get('wtp.locationSelector.updateTimeout') * 1000); LocationSelector.instance = this; @@ -113,7 +114,7 @@ class LocationSelector { } const filtered = Object.keys(newLocations) - .filter(key => key.includes("_US_")) // we only want US-based instances + .filter(key => this.allowRegex.test(key)) .reduce((arr, key) => { return [...arr, newLocations[key]]; }, []);