Skip to content

Commit

Permalink
fix(javascript): smartConnect will apply a default config decorator
Browse files Browse the repository at this point in the history
sessionURL will automatically replace USE_HOSTNAME=location.hostname or USE_HOST=location.host
  • Loading branch information
jourdain committed Aug 10, 2021
1 parent 1fcc39e commit 11ce5a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions js/src/SmartConnect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import CompositeClosureHelper from '../CompositeClosureHelper';
import ProcessLauncher from '../ProcessLauncher';
import WebsocketConnection from '../WebsocketConnection';

function DEFAULT_CONFIG_DECORATOR(config) {
if (config.sessionURL) {
config.sessionURL = config.sessionURL.replaceAll('USE_HOSTNAME', window.location.hostname);
config.sessionURL = config.sessionURL.replaceAll('USE_HOST', window.location.host);
}
return config;
}

export const DEFAULT_SESSION_MANAGER_URL = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/paraview/`,
DEFAULT_SESSION_URL = `${
window.location.protocol === 'https' ? 'wss' : 'ws'
Expand Down Expand Up @@ -51,6 +59,8 @@ function smartConnect(publicAPI, model) {
if (model.configDecorator) {
model.config = model.configDecorator(model.config);
}
model.config = DEFAULT_CONFIG_DECORATOR(model.config);

if (model.config.sessionURL) {
// We have a direct connection URL
session = wsConnect(publicAPI, model);
Expand Down

0 comments on commit 11ce5a6

Please sign in to comment.