Browse Source

fix(last-n-limits): crash on undefined

j8
paweldomas 5 years ago
parent
commit
4adaa6f1fd

+ 4
- 0
react/features/base/lastn/functions.js View File

@@ -40,6 +40,10 @@ export function validateLastNLimits(lastNLimits) {
40 40
  * of participants or {@code undefined} otherwise.
41 41
  */
42 42
 export function limitLastN(participantsCount, lastNLimits) {
43
+    if (!lastNLimits || !lastNLimits.keys) {
44
+        return undefined;
45
+    }
46
+
43 47
     let selectedLimit;
44 48
 
45 49
     for (const participantsN of lastNLimits.keys()) {

+ 4
- 1
react/features/base/lastn/functions.test.js View File

@@ -1,6 +1,9 @@
1 1
 import { limitLastN, validateLastNLimits } from './functions';
2 2
 
3
-describe('limitsLastN', () => {
3
+describe('limitLastN', () => {
4
+    it('handles undefined mapping', () => {
5
+        expect(limitLastN(0, undefined)).toBe(undefined);
6
+    });
4 7
     describe('when a correct limit mapping is given', () => {
5 8
         const limits = new Map();
6 9
 

Loading…
Cancel
Save