Skip to content

Commit

Permalink
update pricing-proxy worker
Browse files Browse the repository at this point in the history
  • Loading branch information
aorcsik committed Sep 2, 2024
1 parent bf4f24c commit 634f06b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/js/pricing/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ 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,
headers: Object.fromEntries(response.headers.entries()),
});
}

urlObject.pathname = urlObject.pathname.replace('plans-pricing-test', 'plans-pricing');
urlObject.pathname = `/${actualPath}`;

return fetch(urlObject);
},
Expand Down

0 comments on commit 634f06b

Please sign in to comment.