Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions study-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ async function handleContact(request, env) {
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.hostname === "seniorstudy.org" && url.pathname === "/") {
if (url.pathname === "/study" || url.pathname === "/study/" ||
(url.hostname === "seniorstudy.org" && url.pathname === "/")) {
url.pathname = "/study/";
return env.ASSETS.fetch(new Request(url, request));
const asset = await env.ASSETS.fetch(new Request(url, request));
const response = new Response(asset.body, asset);
response.headers.set("Cache-Control", "no-store");
return response;
}
if (url.pathname === "/api/study-contact") {
return handleContact(request, env);
Expand Down
7 changes: 6 additions & 1 deletion study-contact.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ describe("worker.fetch routing", () => {
return new Response(new URL(request.url).pathname === "/study/" ? "study" : "company");
} } };
const company = await worker.fetch(new Request(`${ORIGIN}/`), env);
const direct = await worker.fetch(new Request(`${ORIGIN}/study`), env);
const study = await worker.fetch(new Request(`${ORIGIN}/study/`), env);
const alias = await worker.fetch(new Request("https://seniorstudy.org/?ref=flyer"), env);
expect(await company.text()).toBe("company");
expect(await direct.text()).toBe("study");
expect(direct.status).toBe(200);
expect(direct.headers.get("location")).toBeNull();
expect(direct.headers.get("cache-control")).toBe("no-store");
expect(await study.text()).toBe("study");
expect(await alias.text()).toBe("study");
expect(requests).toEqual([`${ORIGIN}/`, `${ORIGIN}/study/`, "https://seniorstudy.org/study/?ref=flyer"]);
expect(requests).toEqual([`${ORIGIN}/`, `${ORIGIN}/study/`, `${ORIGIN}/study/`, "https://seniorstudy.org/study/?ref=flyer"]);
});

it("counts multibyte input toward the request size limit", async () => {
Expand Down
Loading