@@ -2,7 +2,8 @@ import { Noun } from '@urbit/nockjs';
2
2
import _ from 'lodash' ;
3
3
4
4
import { createDevLogger , escapeLog , runIfDev } from '../debug' ;
5
- import { AnalyticsEvent } from '../domain' ;
5
+ import { AnalyticsEvent , getConstants } from '../domain' ;
6
+ import * as Hosting from '../domain/hosting' ;
6
7
import {
7
8
AuthError ,
8
9
ChannelStatus ,
@@ -106,7 +107,19 @@ export const getCurrentUserIsHosted = () => {
106
107
throw new Error ( 'Client not initialized' ) ;
107
108
}
108
109
109
- return client . url . endsWith ( 'tlon.network' ) ;
110
+ // prefer referencing client URL if available
111
+ if ( client . url ) {
112
+ return Hosting . nodeUrlIsHosted ( client . url ) ;
113
+ }
114
+
115
+ /*
116
+ On web, client URL is implicit based on location
117
+ Note: during development, the true URL is supplied via the environment. Localhost is
118
+ set up to redirect there
119
+ */
120
+ const env = getConstants ( ) ;
121
+ const implicitUrl = __DEV__ ? env . DEV_SHIP_URL : window . location . hostname ;
122
+ return Hosting . nodeUrlIsHosted ( implicitUrl ) ;
110
123
} ;
111
124
112
125
export function internalConfigureClient ( {
@@ -119,7 +132,6 @@ export function internalConfigureClient({
119
132
onQuitOrReset,
120
133
onChannelStatusChange,
121
134
} : ClientParams ) {
122
- logger . log ( 'configuring client' , shipName , shipUrl ) ;
123
135
config . client = config . client || new Urbit ( shipUrl , '' , '' , fetchFn ) ;
124
136
config . client . verbose = verbose ;
125
137
config . client . nodeId = preSig ( shipName ) ;
0 commit comments