mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
28 lines
746 B
JavaScript
28 lines
746 B
JavaScript
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
define([
|
|
'/api/config'
|
|
], function (ApiConfig) {
|
|
var Config = {};
|
|
|
|
Config.getWebsocketURL = function (origin) {
|
|
var path = ApiConfig.websocketPath || '/cryptpad_websocket';
|
|
if (/^ws{1,2}:\/\//.test(path)) { return path; }
|
|
|
|
var l = window.location;
|
|
if (origin && window && window.document) {
|
|
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;
|
|
});
|