Skip to content

Commit

Permalink
feat: add xman redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitdalal committed May 5, 2024
1 parent e3dfa62 commit 443f76c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const URLS = {
twitter: "https://twitter.com/arpitdalal_dev/",
youtube: "https://youtube.com/@arpitdalal_dev/",
mail: "mailto:[email protected]",
xman: "https://xman.arpitdalal.dev/",
};

function blogHandler(req, res, pathToRemove) {
Expand Down Expand Up @@ -122,6 +123,10 @@ app.get("/email", (_, res) => {
res.redirect(URLS.mail);
});

app.get("/xman/:path(*)?", (req, res) => {
res.redirect(prepareUrl(req, "/xman", URLS.xman));
});

app.get("/healthcheck", (_, res) => {
res.send("OK");
});
Expand Down
21 changes: 21 additions & 0 deletions tests/xman.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test, expect } from "@playwright/test";

test('"/xman" redirects to "xman.arpitdalal.dev/" with utm params', async ({
page,
}) => {
await page.goto("/xman");

await expect(page).toHaveURL(
"https://xman.arpitdalal.dev/?utm_source=arpit.im&utm_medium=redirect&utm_campaign=url-shortener"
);
});

test('"/xman/app/dashboard" redirects to "xman.arpitdalal.dev/login" with utm params', async ({
page,
}) => {
await page.goto("/xman/app/dashboard");

await expect(page).toHaveURL(
"https://xman.arpitdalal.dev/login?redirectTo=%2Fapp%2Fdashboard%3Futm_source%3Darpit.im%26utm_medium%3Dredirect%26utm_campaign%3Durl-shortener"
);
});

0 comments on commit 443f76c

Please sign in to comment.