Ver código fonte

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

j8
paweldomas 5 anos atrás
pai
commit
4adaa6f1fd

+ 4
- 0
react/features/base/lastn/functions.js Ver arquivo

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

+ 4
- 1
react/features/base/lastn/functions.test.js Ver arquivo

1
 import { limitLastN, validateLastNLimits } from './functions';
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
     describe('when a correct limit mapping is given', () => {
7
     describe('when a correct limit mapping is given', () => {
5
         const limits = new Map();
8
         const limits = new Map();
6
 
9
 

Carregando…
Cancelar
Salvar