diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/platform.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js index cfa4d87..a3fb80b 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js @@ -39,6 +39,17 @@ export function hubBase() { return bridge ? (bridge.hubBase() || '') : ''; } +/** + * The hub's own address, as somebody else would type it — for a link that is + * sent to another person, where "same origin" means nothing. In a browser the + * hub served this page, so it is the page's origin; in the app it is the + * configured hub. Decided here and nowhere else, like `hubBase()`. + */ +export function hubOrigin() { + const base = hubBase(); + return (base ? new URL(base).origin : window.location.origin); +} + /** Native-only capabilities. A browser renders none of what these gate. */ export const capabilities = { // Install, configure and drive a node running on this machine. |