You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
579 B

  1. define([
  2. '/api/config'
  3. ], function (ApiConfig) {
  4. var Config = {};
  5. Config.getWebsocketURL = function (origin) {
  6. var path = ApiConfig.websocketPath;
  7. if (/^ws{1,2}:\/\//.test(path)) { return path; }
  8. var l = window.location;
  9. if (origin && window && window.document) {
  10. l = document.createElement("a");
  11. l.href = origin;
  12. }
  13. var protocol = l.protocol.replace(/http/, 'ws');
  14. var host = l.host;
  15. var url = protocol + '//' + host + path;
  16. return url;
  17. };
  18. return Config;
  19. });