go-ucan icon indicating copy to clipboard operation
go-ucan copied to clipboard

fix(selector): handle broken "Pass" cases

Open fabiobozzo opened this issue 5 months ago • 0 comments

Test Case Status
Optional Null Iterator
Optional Iterator
String Index
Bytes Index [0]
Bytes Index [1:]
Array Slice [0:2]
Array Slice [1:]
Array Slice [:2]
String Slice [0:2]

CHANGELOG

  • Added support for indexing into strings and byte arrays.
  • Implemented array slicing for lists, strings, and byte arrays.
  • Handled negative indices for array slicing and indexing.
  • Added support for optional null iterators, returning an empty list node when applicable.
  • Modified the iterator case to handle nested iterators correctly:
    • Recursively resolved remaining selector segments for nested lists.
    • Handled optional segments by skipping iterations when errors occur.
    • Appended single nodes and slices of nodes to the result appropriately.
  • Updated the iterator case to handle non-list elements:
    • Skipped non-list elements when the next segment is optional.
    • Returned an error when the next segment is not optional and the current value is not a list.

Refactoring to reduce duplication and improve readability:

  • Extracted common logic for resolving slice indices into a separate function.
  • Switch statements to handle different segment types and node kinds.

fabiobozzo avatar Sep 12 '24 16:09 fabiobozzo