|
|
|
@ -3,21 +3,28 @@ import appStore from "../state/store" |
|
|
|
import { parseAppIdFromCookie } from "./getAppId" |
|
|
|
|
|
|
|
export const screenRouter = ({ screens, onScreenSelected, window }) => { |
|
|
|
const isRunningLocally = () => { |
|
|
|
const hostname = (window.location && window.location.hostname) || "" |
|
|
|
return ( |
|
|
|
hostname === "localhost" || |
|
|
|
hostname === "127.0.0.1" || |
|
|
|
hostname.startsWith("192.168") |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
const makeRootedPath = url => { |
|
|
|
const hostname = window.location && window.location.hostname |
|
|
|
if (hostname) { |
|
|
|
if ( |
|
|
|
hostname === "localhost" || |
|
|
|
hostname === "127.0.0.1" || |
|
|
|
hostname.startsWith("192.168") |
|
|
|
) { |
|
|
|
const appId = parseAppIdFromCookie(window.document.cookie) |
|
|
|
if (url) { |
|
|
|
if (url.startsWith(appId)) return url |
|
|
|
return `/${appId}${url.startsWith("/") ? "" : "/"}${url}` |
|
|
|
if (isRunningLocally()) { |
|
|
|
const appId = parseAppIdFromCookie(window.document.cookie) |
|
|
|
if (url) { |
|
|
|
if (!url.startsWith("/")) { |
|
|
|
url = `/${url}` |
|
|
|
} |
|
|
|
if (url.startsWith(`/${appId}`)) { |
|
|
|
return url |
|
|
|
} |
|
|
|
return appId |
|
|
|
return `/${appId}${url}` |
|
|
|
} |
|
|
|
return `/${appId}` |
|
|
|
} |
|
|
|
return url |
|
|
|
} |
|
|
|
|