core-app-worona
Advanced tools
Comparing version 1.5.9 to 1.5.10
{ | ||
"name": "core-app-worona", | ||
"version": "1.5.9", | ||
"version": "1.5.10", | ||
"description": "Core Package of Worona App", | ||
@@ -5,0 +5,0 @@ "scripts": { |
/* eslint-disable react/prefer-stateless-function, react/no-multi-comp, react/prop-types | ||
eslint-disable prefer-template, react/prefer-es6-class, react/jsx-filename-extension, camelcase, | ||
react/no-unused-prop-types */ | ||
react/no-unused-prop-types, no-undef */ | ||
import React from 'react'; | ||
@@ -45,13 +45,12 @@ import { dep } from 'worona-deps'; | ||
const addSiteId = store => | ||
const addSiteIdAndBaseHref = store => | ||
(prevState, nextState, replace) => { | ||
if (!nextState.location.query.siteId) { | ||
const siteId = store.getState().router.siteId; | ||
if (siteId) { | ||
replace({ | ||
pathname: nextState.location.pathname, | ||
query: { ...nextState.location.query, siteId }, | ||
}); | ||
} | ||
} | ||
const pathname = /^file.+index\.html/.test(window.location.href) | ||
? /(.+index\.html)/.exec(window.location.href)[1] + nextState.location.pathname | ||
: nextState.location.pathname; | ||
const query = !nextState.location.query.siteId | ||
? { ...nextState.location.query, siteId: store.getState().router.siteId } | ||
: nextState.location.query; | ||
if (pathname !== nextState.location.pathname || query !== nextState.location.query) | ||
replace({ pathname, query }); | ||
}; | ||
@@ -61,4 +60,4 @@ | ||
<Route path="/" component={ThemeLoader}> | ||
<IndexRoute component={Content} onChange={addSiteId(store)} /> | ||
<Route path="*" component={Content} onChange={addSiteId(store)} /> | ||
<IndexRoute component={Content} onChange={addSiteIdAndBaseHref(store)} /> | ||
<Route path="*" component={Content} onChange={addSiteIdAndBaseHref(store)} /> | ||
</Route> | ||
@@ -65,0 +64,0 @@ ); |
96861
1367