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.

URLProcessor.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* global config, interfaceConfig, loggingConfig, getConfigParamsFromUrl */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var configUtils = require('./Util');
  4. var params = {};
  5. params = getConfigParamsFromUrl();
  6. var URLProcessor = {
  7. setConfigParametersFromUrl: function () {
  8. // Convert 'params' to JSON object
  9. // We have:
  10. // {
  11. // "config.disableAudioLevels": false,
  12. // "config.channelLastN": -1,
  13. // "interfaceConfig.APP_NAME": "Jitsi Meet"
  14. // }
  15. // We want to have:
  16. // {
  17. // "config": {
  18. // "disableAudioLevels": false,
  19. // "channelLastN": -1
  20. // },
  21. // interfaceConfig: {
  22. // APP_NAME: "Jitsi Meet"
  23. // }
  24. // }
  25. var configJSON = {
  26. config: {},
  27. interfaceConfig: {},
  28. loggingConfig: {}
  29. };
  30. for (var key in params) {
  31. if (typeof key !== "string") {
  32. logger.warn("Invalid config key: ", key);
  33. continue;
  34. }
  35. var confObj = null, confKey;
  36. if (key.indexOf("config.") === 0) {
  37. confObj = configJSON.config;
  38. confKey = key.substr("config.".length);
  39. // prevent passing some parameters which can inject scripts
  40. if (confKey === 'analyticsScriptUrls'
  41. || confKey === 'callStatsCustomScriptUrl')
  42. continue;
  43. } else if (key.indexOf("interfaceConfig.") === 0) {
  44. confObj = configJSON.interfaceConfig;
  45. confKey = key.substr("interfaceConfig.".length);
  46. } else if (key.indexOf("loggingConfig.") === 0) {
  47. confObj = configJSON.loggingConfig;
  48. confKey = key.substr("loggingConfig.".length);
  49. }
  50. if (!confObj)
  51. continue;
  52. confObj[confKey] = params[key];
  53. }
  54. configUtils.overrideConfigJSON(
  55. config, interfaceConfig, loggingConfig, configJSON);
  56. }
  57. };
  58. module.exports = URLProcessor;