Skip to content

Commit

Permalink
integrations worker
Browse files Browse the repository at this point in the history
  • Loading branch information
aorcsik committed Feb 1, 2024
1 parent 8ca9c11 commit 74fe966
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/js/integrations/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const routingRules = [
[/^\/integrations\/steps\/.+/, '/integrations/steps', 'webflow.bitrise.io'],
[/\/integrations$|integrations\/(.*)/, '/integrations', 'webflow.bitrise.io'],
];

addEventListener('fetch', event => {
let urlObject = new URL(event.request.url);
for (let routingRule of routingRules) {
const match = urlObject.pathname.match(routingRule[0]);
if (match) {
urlObject.hostname = routingRule[2];
urlObject.pathname = urlObject.pathname.replace(routingRule[0], routingRule[1]);
event.respondWith(fetch(urlObject));
break;
}
}
});

0 comments on commit 74fe966

Please sign in to comment.