From 4fe17d95c519facb91f08d3f67f39c8a6fadc67d Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 29 Nov 2020 22:54:21 -0800 Subject: [PATCH] Make trailing slash optional --- src/redux/epics.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/redux/epics.js b/src/redux/epics.js index fb597050..30dd3510 100644 --- a/src/redux/epics.js +++ b/src/redux/epics.js @@ -27,14 +27,16 @@ const urlChangedEpic = (actions) => actions.pipe( filter((action) => action.type === "URL_CHANGED"), switchMap((action) => { - if (action.location.pathname === "/about/") { - return of(Actions.requestedAboutPage()); - } - if (action.location.pathname === "/upload/") { - return of(Actions.requestedUploadPage()); - } - if (action.location.pathname === "/review/") { - return of(Actions.requestedReviewPage()); + const pathname = action.location.pathname.replace("/$", ""); + switch (pathname) { + case "/about": + return of(Actions.requestedAboutPage()); + case "/upload": + return of(Actions.requestedUploadPage()); + case "/review": + return of(Actions.requestedReviewPage()); + default: + // } const params = new URLSearchParams(action.location.search); const query = params != null && params.get("query");