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

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