From a9c461057f9258b88aa9e8882f1664cb2238b7e6 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Tue, 6 Aug 2024 13:25:04 -0700 Subject: [PATCH] changeURLMiddleware: respect `pathnameShouldBe: ""` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prompted by @jameshadfield's review comment.¹ Fixes bug where ` pathnameShouldBe: ""` was ignored because `""` is falsey. I chose to check `typeof` instead of `action.hasOwnProperty` because I found cases where `pathnameShouldBe` can potentially be set to `undefined`.² ¹ ² --- src/middleware/changeURL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/changeURL.js b/src/middleware/changeURL.js index cd44259cc..b8adce4be 100644 --- a/src/middleware/changeURL.js +++ b/src/middleware/changeURL.js @@ -229,7 +229,7 @@ export const changeURLMiddleware = (store) => (next) => (action) => { /* second switch: path change */ switch (action.type) { case types.CLEAN_START: - if (action.pathnameShouldBe && !action.narrative) { + if (typeof action.pathnameShouldBe === "string" && !action.narrative) { pathname = action.pathnameShouldBe; break; }