You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the path in the get function has values that are empty or undefined, the subsequent paths' values are incorrectly computed due to wrong index calculations. This issue causes the function to return incorrect values and doesn't handle the skipping of such paths effectively.
The Fuse.js version where this bug is happening.
6.6.2
Is this a regression?
This is a regression bug
Which version did this behavior use to work in?
None
Steps To Reproduce
Create an object with nested properties, some of which are undefined or empty.
Call the fuse.search.
Example test case:
describe('Recurse into objects in arrays with null object in array',()=>{constcustomSearchCase=[{"blocks": [{"id": "cd091ca6-a039-4e93-b510-3637f9cb6e3d","type": "paragraph","props": {"textColor": "default","backgroundColor": "default","textAlignment": "left"},"content": [{"type": "text","text": "This content has a text.","styles": {}}],"children": []},{"id": "e78f03d7-db8f-4024-a0d0-269990a23fae","type": "checkListItem","props": {"textColor": "default","backgroundColor": "default","textAlignment": "left","checked": false},"content": [{"type": "text","text": "This content has a text 2","styles": {}}],"children": []},{"id": "e723f652-bbd7-49c6-96c1-41790b43616f","type": "paragraph","props": {"textColor": "default","backgroundColor": "default","textAlignment": "left"},"content": [],"children": []},{"id": "3d30ea0d-59a6-4595-bff5-223c307924ef","type": "checkListItem","props": {"textColor": "default","backgroundColor": "default","textAlignment": "left","checked": false},"content": [{"type": "text","text": "This content will be have wrong refIndex.","styles": {}}],"children": []},],"fileName": "2024-11-25.md"},]constcustomOptions={keys: ['blocks.content.text'],threshold: 0.4,includeMatches: true,}letfusebeforeEach(()=>(fuse=setup(customSearchCase,customOptions)))describe('When searching nested empty path',()=>{letresultbeforeEach(()=>(result=fuse.search('This content will be have wrong refIndex')))test('Result content refIndex must be 4',()=>{constrefIndex=result[0].matches[0].refIndex;expect(refIndex).eq(4)})})})
Expected behavior
Modify the deepGet function to account for undefined or empty path values without skipping them. This involves adjusting the index management logic to ensure it tracks paths correctly even when encountering undefined or empty values.
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Description of the bug
When the path in the
get
function has values that are empty or undefined, the subsequent paths' values are incorrectly computed due to wrong index calculations. This issue causes the function to return incorrect values and doesn't handle the skipping of such paths effectively.The Fuse.js version where this bug is happening.
6.6.2
Is this a regression?
Which version did this behavior use to work in?
None
Steps To Reproduce
Example test case:
Expected behavior
Modify the
deepGet
function to account for undefined or empty path values without skipping them. This involves adjusting the index management logic to ensure it tracks paths correctly even when encountering undefined or empty values.Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: