You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
656 B
JavaScript
25 lines
656 B
JavaScript
define([
|
|
'/api/config'
|
|
], function (ApiConfig) {
|
|
var Config = {};
|
|
|
|
Config.getWebsocketURL = function (origin) {
|
|
if (!ApiConfig.websocketPath) { return ApiConfig.websocketURL; }
|
|
var path = ApiConfig.websocketPath;
|
|
if (/^ws{1,2}:\/\//.test(path)) { return path; }
|
|
|
|
var l = window.location;
|
|
if (origin && window && window.document) {
|
|
var l = document.createElement("a");
|
|
l.href = origin;
|
|
}
|
|
var protocol = l.protocol.replace(/http/, 'ws');
|
|
var host = l.host;
|
|
var url = protocol + '//' + host + path;
|
|
|
|
return url;
|
|
};
|
|
|
|
return Config;
|
|
});
|