Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
Improve readability of currentLocation related logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Søvik committed Dec 3, 2016
1 parent 6702d26 commit 10606d1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function reactRender({
reduxSagas,
}) {
return new Promise((resolve) => {
let currentLocation = {};
let currentLocation;

history.listen((location) => {
currentLocation = location;
Expand All @@ -91,7 +91,7 @@ export function reactRender({
match({ history, routes: createRoutes(store), location: url },
(error, redirect, renderProps) => {
if (redirect) {
const base = redirect.basename ? redirect.basename : '';
const base = redirect.basename || '';
const redirectUrl = `${base}${redirect.pathname}${redirect.search}`;
log(`Redirect request to ${redirectUrl} due to React Router`);

Expand Down Expand Up @@ -138,11 +138,11 @@ export function reactRender({
}
return result;
}).then(({ redialMap, redialProps }) => {
if (Object.keys(currentLocation).length > 0) {
if (currentLocation) {
const currentUrl = `${currentLocation.pathname}${currentLocation.search}`;

if (currentUrl !== url) {
const base = currentLocation.basename ? currentLocation.basename : '';
const base = currentLocation.basename || '';
const redirectUrl = `${base}${currentUrl}`;

log(`Redirect request to ${redirectUrl} due to history location modification`);
Expand Down

0 comments on commit 10606d1

Please sign in to comment.