joyent-portal/consoles/my-joy-images/src/state/global.js

30 lines
828 B
JavaScript
Raw Normal View History

import { canUseDOM } from 'exenv';
2018-05-23 19:29:04 +03:00
import queryString from 'query-string';
2018-05-23 19:29:04 +03:00
const { NODE_ENV = 'development' } = process.env;
export const Global = () => {
if (!canUseDOM) {
2018-03-07 17:36:32 +02:00
return {
2018-05-23 19:29:04 +03:00
protocol: NODE_ENV === 'development' ? 'http:' : 'https:',
2018-03-07 17:36:32 +02:00
cookie: ''
};
}
return {
port: window.location.port,
protocol: window.location.protocol.replace(/:$/, ''),
hostname: window.location.hostname,
2018-05-23 19:29:04 +03:00
pathname: window.location.pathname,
2018-03-06 03:14:33 +02:00
origin: window.location.origin,
2018-03-07 17:36:32 +02:00
cookie: document.cookie || '',
2018-05-23 19:29:04 +03:00
search: window.location.search,
query: queryString.parse(window.location.search || ''),
__REDUX_DEVTOOLS_EXTENSION__: window.__REDUX_DEVTOOLS_EXTENSION__,
__APOLLO_STATE__: window.__APOLLO_STATE__,
__REDUX_STATE__: window.__REDUX_STATE__
};
2018-05-23 19:29:04 +03:00
};
export default Global();