Skip to content

Commit

Permalink
Merge pull request #16247 from Nexus-Mods/16234-crash-on-skippable-ob…
Browse files Browse the repository at this point in the history
…ject-properties

fixed crash when comparing objects with skippable properties
  • Loading branch information
insomnious committed Aug 14, 2024
1 parent 2b88cd5 commit 65292a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import { NEXUS_DOMAIN, NEXUS_FLAMEWORK_SUBDOMAIN, NEXUS_NEXT_SUBDOMAIN, NEXUS_PROTOCOL, NEXUS_USERS_SUBDOMAIN } from '../extensions/nexus_integration/constants';

import { TimeoutError } from './CustomErrors';
Expand Down Expand Up @@ -107,14 +108,14 @@ export function objDiff(lhs: any, rhs: any, skip?: string[]): any {
if ((typeof(lhs) === 'object') && (typeof(rhs) === 'object')) {
Object.keys(lhs || {}).forEach(key => {
if ((skip !== undefined) && Array.isArray(skip) && (skip.indexOf(key) !== -1)) {
return;
return null;
}
if (!Object.prototype.hasOwnProperty.call(rhs, key)
&& Object.prototype.hasOwnProperty.call(lhs, key)) {
res['-' + key] = lhs[key];
} else {
const sub = objDiff(lhs?.[key] ?? {}, rhs?.[key] ?? {});
if (sub === null) {
if (sub === null || sub === undefined) {
res['-' + key] = lhs?.[key] ?? null;
res['+' + key] = rhs?.[key] ?? null;
} else if (Object.keys(sub).length !== 0) {
Expand Down

0 comments on commit 65292a4

Please sign in to comment.