您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

URLProcessor.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* global config, interfaceConfig, loggingConfig */
  2. import { parseURLParams } from '../../react/features/base/config';
  3. import configUtils from './Util';
  4. const logger = require("jitsi-meet-logger").getLogger(__filename);
  5. /**
  6. * URL params with this prefix should be merged to config.
  7. */
  8. const CONFIG_PREFIX = 'config.';
  9. /**
  10. * URL params with this prefix should be merged to interface config.
  11. */
  12. const INTERFACE_CONFIG_PREFIX = 'interfaceConfig.';
  13. /**
  14. * Config keys to be ignored.
  15. *
  16. * @type Set
  17. */
  18. const KEYS_TO_IGNORE = new Set([
  19. 'analyticsScriptUrls',
  20. 'callStatsCustomScriptUrl'
  21. ]);
  22. /**
  23. * URL params with this prefix should be merged to logging config.
  24. */
  25. const LOGGING_CONFIG_PREFIX = 'loggingConfig.';
  26. /**
  27. * Convert 'URL_PARAMS' to JSON object
  28. * We have:
  29. * {
  30. * "config.disableAudioLevels": false,
  31. * "config.channelLastN": -1,
  32. * "interfaceConfig.APP_NAME": "Jitsi Meet"
  33. * }
  34. * We want to have:
  35. * {
  36. * "config": {
  37. * "disableAudioLevels": false,
  38. * "channelLastN": -1
  39. * },
  40. * interfaceConfig: {
  41. * "APP_NAME": "Jitsi Meet"
  42. * }
  43. * }
  44. */
  45. export function setConfigParametersFromUrl() {
  46. // Parsing config params from URL hash.
  47. const params = parseURLParams(window.location);
  48. const configJSON = {
  49. config: {},
  50. interfaceConfig: {},
  51. loggingConfig: {}
  52. };
  53. for (const key in params) {
  54. if (typeof key === 'string') {
  55. let confObj = null;
  56. let confKey;
  57. if (key.indexOf(CONFIG_PREFIX) === 0) {
  58. confObj = configJSON.config;
  59. confKey = key.substr(CONFIG_PREFIX.length);
  60. } else if (key.indexOf(INTERFACE_CONFIG_PREFIX) === 0) {
  61. confObj = configJSON.interfaceConfig;
  62. confKey
  63. = key.substr(INTERFACE_CONFIG_PREFIX.length);
  64. } else if (key.indexOf(LOGGING_CONFIG_PREFIX) === 0) {
  65. confObj = configJSON.loggingConfig;
  66. confKey = key.substr(LOGGING_CONFIG_PREFIX.length);
  67. }
  68. // prevent passing some parameters which can inject scripts
  69. if (confObj && !KEYS_TO_IGNORE.has(confKey)) {
  70. confObj[confKey] = params[key];
  71. }
  72. } else {
  73. logger.warn('Invalid config key: ', key);
  74. }
  75. }
  76. configUtils.overrideConfigJSON(
  77. config, interfaceConfig, loggingConfig,
  78. configJSON);
  79. }