Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
fpbrault committed Aug 7, 2024
1 parent a5c9b61 commit e0829fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function buildStringTemplateFromProduct(

if (!newValue) {
bindings.engine.logger.warn(
`${key} used in the href template is undefined for this product: ${product.permanentid} and not found in the window object.`
`${key} used in the href template is undefined for this product: ${product.permanentid} and could not be found in the window object.`
);
return '';
}
Expand All @@ -37,20 +37,10 @@ export function buildStringTemplateFromProduct(
});
}

function readFromObject<T extends object>(
object: T,
key: string
): string | undefined {
const keys = key.split('.');
let current: unknown = object;

for (const k of keys) {
if (current && typeof current === 'object' && k in current) {
current = (current as Record<string, unknown>)[k];
} else {
return undefined;
}
function readFromObject<T>(object: T, key: string): string | undefined {
if (object && typeof object === 'object' && key in object) {
const value = (object as Record<string, unknown>)[key];
return typeof value === 'string' ? value : undefined;
}

return typeof current === 'string' ? current : undefined;
return undefined;
}
2 changes: 1 addition & 1 deletion packages/atomic/src/utils/result-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function buildStringTemplateFromResult(

if (!newValue) {
bindings.engine.logger.warn(
`${key} used in the href template is undefined for this result: ${result.uniqueId} and not found in the window object.`
`${key} used in the href template is undefined for this result: ${result.uniqueId} and could not be found in the window object.`
);
return '';
}
Expand Down

0 comments on commit e0829fe

Please sign in to comment.