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

24 lines
604 B
JavaScript
Raw Normal View History

2017-11-23 11:28:49 +00:00
define([
'/api/config'
], function (ApiConfig) {
var Config = {};
2019-12-17 09:57:13 +00:00
Config.getWebsocketURL = function (origin) {
var path = ApiConfig.websocketPath || '/cryptpad_websocket';
2017-11-23 11:28:49 +00:00
if (/^ws{1,2}:\/\//.test(path)) { return path; }
2019-12-17 09:57:13 +00:00
var l = window.location;
if (origin && window && window.document) {
2019-12-17 10:49:32 +00:00
l = document.createElement("a");
2019-12-17 09:57:13 +00:00
l.href = origin;
}
var protocol = l.protocol.replace(/http/, 'ws');
var host = l.host;
2017-11-23 11:28:49 +00:00
var url = protocol + '//' + host + path;
return url;
};
return Config;
});