cryptpad/www/common/outer/network-config.js

20 lines
506 B
JavaScript
Raw Normal View History

2017-11-23 11:28:49 +00:00
define([
'/api/config'
], function (ApiConfig) {
var Config = {};
Config.getWebsocketURL = function () {
if (!ApiConfig.websocketPath) { return ApiConfig.websocketURL; }
var path = ApiConfig.websocketPath;
if (/^ws{1,2}:\/\//.test(path)) { return path; }
var protocol = window.location.protocol.replace(/http/, 'ws');
var host = window.location.host;
var url = protocol + '//' + host + path;
return url;
};
return Config;
});