Skip to content

Commit

Permalink
fix: Fix NaN and empty objects in getNonDefaultConfiguration (#6956)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jul 2, 2024
1 parent fa9feb3 commit 52e3864
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/util/config_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ shaka.util.ConfigUtils = class {
}
} else if (isArrayEmpty(value) && isArrayEmpty(base[key])) {
// Do nothing if both are empty arrays
} else if (Number.isNaN(value) && Number.isNaN(base[key])) {
// Do nothing if both are NaN
} else if (value !== base[key]) {
acc[key] = value;
}
Expand All @@ -215,6 +217,9 @@ shaka.util.ConfigUtils = class {
delete obj[key];
} else if (isObject(obj[key])) {
removeEmpty(obj[key]);
if (Object.keys(obj[key]).length === 0) {
delete obj[key];
}
}
}
};
Expand Down
6 changes: 6 additions & 0 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,13 +772,19 @@ describe('Player', () => {

it('getNonDefaultConfiguration', () => {
player.configure({
manifest: {
disableThumbnails: true,
},
drm: {
retryParameters: {backoffFactor: 5},
},
});
const nonDefaultConfiguration = player.getNonDefaultConfiguration();
const config = player.getConfiguration();
expect(nonDefaultConfiguration).not.toBe(config);
expect(nonDefaultConfiguration['mediaSource']).toBeUndefined();
expect(nonDefaultConfiguration['manifest']['availabilityWindowOverride'])
.toBeUndefined();
});

describe('configure', () => {
Expand Down

0 comments on commit 52e3864

Please sign in to comment.