asyncfunctionhandleRequest(request) { let random = Math.random() let sum = WEIGHTS.reduce((a, b) => a + b, 0) random = random * sum let target = null let acc = 0 for (let i = 0; i < TARGETS.length; i++) { acc += WEIGHTS[i] if (random < acc) { target = TARGETS[i] break } } let url = newURL(request.url) let targetUrl = newURL(target) url.protocol = targetUrl.protocol url.hostname = targetUrl.hostname url.pathname = targetUrl.pathname url.search = targetUrl.search url.hash = targetUrl.hash let newRequest = newRequest(url, request) returnawaitfetch(newRequest) }