Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(config): allow overriding nested config objects

Saúl Ibarra Corretgé4e5bc172c909
diff --git a/react/features/base/config/functions.js b/react/features/base/config/functions.js
index e2c615ec16..7f562acb4b 100644
--- a/react/features/base/config/functions.js
+++ b/react/features/base/config/functions.js
@@ -1,6 +1,7 @@
/* @flow */
import JSSHA from 'jssha';
+import _ from 'lodash';
import parseURLParams from './parseURLParams';
@@ -172,17 +173,11 @@ export function overrideConfigJSON(
if (configObj) {
const configJSON = json[configName];
- for (const key of Object.keys(configJSON)) {
- const oldValue = configObj[key];
- const newValue = configJSON[key];
-
- if (oldValue && typeof oldValue !== typeof newValue) {
- logger.log(
- `Overriding a ${configName
- } property with a property of different type.`);
- }
- logger.info(`Overriding ${key} with: ${newValue}`);
- configObj[key] = newValue;
+ if (!_.isEmpty(configJSON)) {
+ logger.info(
+ `Extending ${configName} `
+ + `with: ${JSON.stringify(configJSON)}`);
+ _.merge(configObj, configJSON);
}
}
}
@@ -227,20 +222,21 @@ export function setConfigFromURLParams() {
loggingConfig && (json.loggingConfig = {});
for (const param of Object.keys(params)) {
- const objEnd = param.indexOf('.');
-
- if (objEnd !== -1) {
- const obj = param.substring(0, objEnd);
-
- if (json.hasOwnProperty(obj)) {
- const key = param.substring(objEnd + 1);
+ let base = json;
+ const names = param.split('.');
+ const last = names.pop();
+
+ // Prevent passing some parameters which can inject scripts.
+ if (_KEYS_TO_IGNORE.indexOf(last) !== -1) {
+ // eslint-disable-next-line no-continue
+ continue;
+ }
- // Prevent passing some parameters which can inject scripts.
- if (key && _KEYS_TO_IGNORE.indexOf(key) === -1) {
- json[obj][key] = params[param];
- }
- }
+ for (const name of names) {
+ base = base[name] = base[name] || {};
}
+
+ base[last] = params[param];
}
overrideConfigJSON(config, interfaceConfig, loggingConfig, json);