Skip to content

Commit

Permalink
fix: rawContent was not correctly cloned (hence undefined) (#6549)
Browse files Browse the repository at this point in the history
* fix: rawContent was not correctly cloned (hence undefined)

* chore: more performant cloning
  • Loading branch information
e-krebs authored Jan 28, 2025
1 parent ea8a648 commit 0b2d4af
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/algoliasearch-helper/src/algoliasearch.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1844,8 +1844,11 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');

var results = content.results.slice();
var rawContent = Object.create(content);
delete rawContent.results;
var rawContent = Object.keys(content).reduce(function (value, key) {
if (key !== 'results') value[key] = content[key];
return value;
}, {});

if (Object.keys(rawContent).length <= 0) {
rawContent = undefined;
}
Expand All @@ -1869,12 +1872,11 @@ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
specificResults,
self._searchResultsOptions
);
helper.lastResults._rawContent = rawContent;
if (rawContent !== undefined) helper.lastResults._rawContent = rawContent;

helper.emit('result', {
results: helper.lastResults,
state: state,
_rawContent: rawContent,
});
});
};
Expand Down

0 comments on commit 0b2d4af

Please sign in to comment.