Skip to content

Commit 1c06bff

Browse files
fix: region selection criteria should be configurable (#98)
1 parent ebe329c commit 1c06bff

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const conf = {
3737
},
3838
timeout: process.env.WTP_TIMEOUT || 30000,
3939
"locationSelector": {
40+
"allowRegex": process.env.WTP_LS_ALLOW_REGEX || '_US_',
4041
"cacheTtl": process.env.WTP_LS_CACHE_TTL || 10,
4142
"updateTimeout": process.env.WTP_LS_UPDATE_TIMEOUT || 20,
4243
"defaultLocation": process.env.WTP_LS_DEFAULT_LOCATION || "IAD_US_01"

wtp/apiCaller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const runWtpTest = async (url, mobile, cb) => {
7070
height: config.get('wtp.viewportHeight'),
7171
custom: config.get('wtp.imageScript'),
7272
location: await locationSelector.getLocation() + ':Chrome.Native', // Native means no speed shaping in browser, full speed ahead
73-
mobile: (mobile) ? 1 : 0,
73+
mobile: (mobile) ? 1 : 0,
7474
fvonly: 1, // first view only
7575
timeline: 1 // workaround for WPT sometimes hanging on getComputedStyle()
7676
},

wtp/locationSelector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class LocationSelector {
3131
if (!LocationSelector.instance) {
3232
this.cachedAllLocations = [];
3333
this.location = config.get('wtp.locationSelector.defaultLocation');
34+
this.allowRegex = new RegExp(config.get('wtp.locationSelector.allowRegex'));
3435
this.lastUpdated = null;
3536
this.mutex = withTimeout(new Mutex(), config.get('wtp.locationSelector.updateTimeout') * 1000);
3637
LocationSelector.instance = this;
@@ -113,7 +114,7 @@ class LocationSelector {
113114
}
114115

115116
const filtered = Object.keys(newLocations)
116-
.filter(key => key.includes("_US_")) // we only want US-based instances
117+
.filter(key => this.allowRegex.test(key))
117118
.reduce((arr, key) => {
118119
return [...arr, newLocations[key]];
119120
}, []);

0 commit comments

Comments
 (0)