From 634f06baf42e6088156aaee141a8a89d190e07d4 Mon Sep 17 00:00:00 2001 From: Antal Orcsik Date: Mon, 2 Sep 2024 16:47:32 +0200 Subject: [PATCH] update pricing-proxy worker --- src/js/pricing/worker.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/js/pricing/worker.js b/src/js/pricing/worker.js index 08621fe..cf7f1e3 100644 --- a/src/js/pricing/worker.js +++ b/src/js/pricing/worker.js @@ -4,10 +4,14 @@ export default { urlObject.hostname = 'webflow.bitrise.io'; - if (urlObject.search.match(/us=1/) || request.headers.get('cf-ipcountry') === 'US') { - urlObject.pathname = '/plans-pricing-us'; + const actualPath = 'plans-pricing'; + const variantPath = 'plans-pricing-pro-plan-variant'; + const variantCondition = request.headers.get('cf-ipcountry') === 'US'; + + if (urlObject.search.match(new RegExp(`variant=${variantPath}`)) || variantCondition) { + urlObject.pathname = `/${variantPath}`; const response = await fetch(urlObject); - const data = (await response.text()).replace('plans-pricing-us', 'plans-pricing'); + const data = (await response.text()).replace(variantPath, actualPath); return new Response(data, { status: response.status, statusText: response.statusText, @@ -15,7 +19,7 @@ export default { }); } - urlObject.pathname = urlObject.pathname.replace('plans-pricing-test', 'plans-pricing'); + urlObject.pathname = `/${actualPath}`; return fetch(urlObject); },