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.2KB

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