From 42fe896d7c50677eb75a6988817be2cec52adcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 16 Jul 2026 16:04:05 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20stop=20exam=20pages=20fet?= =?UTF-8?q?ching=20junk=20ids=20while=20navigating=20away=20-=20anchor=20e?= =?UTF-8?q?xam=20detail=20and=20exam=20room=20id=20parsing=20to=20their=20?= =?UTF-8?q?route=20shapes=20-=20keep=20the=20previous=20id=20during=20exit?= =?UTF-8?q?=20transitions=20instead=20of=20adopting=20the=20next=20page's?= =?UTF-8?q?=20last=20path=20segment=20-=20removes=20transient=20GET=20/exa?= =?UTF-8?q?ms/exams=20and=20GET=20/exams/events=20404s=20on=20every=20navi?= =?UTF-8?q?gation=20out=20of=20exam=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exam-detail-page.tsx | 7 ++++++- src/pages/exam-room-page.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index 46e9a60..cdb8c3b 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -62,7 +62,12 @@ function ExamDetailContent() { const t = useT(); const { locale } = usePreferences(); const now = createNow(); - const id = createMemo(() => decodeURIComponent(location().pathname.split("/").pop() ?? "")); + // Keep the previous id while navigating away, so the resource does not + // fetch the next page's path segment (e.g. GET /exams/exams) mid-transition. + const id = createMemo((prev: string) => { + const match = /^\/exams\/([^/]+)$/.exec(location().pathname); + return match ? decodeURIComponent(match[1]) : prev; + }, ""); const [exam, { refetch: refetchExam }] = createResource(id, (examId) => getExamById(examId)); const [settings] = createResource(() => getSettings()); diff --git a/src/pages/exam-room-page.tsx b/src/pages/exam-room-page.tsx index 927e1ec..d35dfe2 100644 --- a/src/pages/exam-room-page.tsx +++ b/src/pages/exam-room-page.tsx @@ -25,7 +25,12 @@ function ExamRoomContent() { const location = useLocation(); const auth = useAuth(); const t = useT(); - const id = createMemo(() => decodeURIComponent(location().pathname.split("/").pop() ?? "")); + // Keep the previous id while navigating away, so the resource does not + // fetch the next page's path segment (e.g. GET /exams/exams) mid-transition. + const id = createMemo((prev: string) => { + const match = /^\/exam-room\/([^/]+)$/.exec(location().pathname); + return match ? decodeURIComponent(match[1]) : prev; + }, ""); const [exam] = createResource(id, (examId) => getExamById(examId)); const [mine] = createResource( () => (auth.user()?.role === "student" ? true : null),