If fromIndex is past the end of the list, splice returns [], so movedItem is undefined, and that hole is inserted at toIndex. A UI that reorders waypoints from a stale index can grow a phantom undefined stop and then crash when building a Directions request (waypoint.location.lat).
removeWaypoint already no-ops for an out-of-range index (filter keeps the list). moveWaypoint should do the same — return unchanged when fromIndex is not in range, rather than inserting undefined.
Would have caught:setWaypoints(['a','b']); moveWaypoint(9, 0) producing [undefined, 'a', 'b'].
Wave 7 tick 5 a3 coverage of `MarksMapStateService.moveWaypoint`.
**Where:** `projects/spikersoft/src/app/_services/marks-site/marks-map/marks-map-state.service.ts`
**What:** `moveWaypoint(fromIndex, toIndex)` does:
```
const [movedItem] = newWaypoints.splice(fromIndex, 1);
newWaypoints.splice(toIndex, 0, movedItem);
```
If `fromIndex` is past the end of the list, `splice` returns `[]`, so `movedItem` is `undefined`, and that hole is inserted at `toIndex`. A UI that reorders waypoints from a stale index can grow a phantom `undefined` stop and then crash when building a Directions request (`waypoint.location.lat`).
`removeWaypoint` already no-ops for an out-of-range index (filter keeps the list). `moveWaypoint` should do the same — return unchanged when `fromIndex` is not in range, rather than inserting `undefined`.
**Would have caught:** `setWaypoints(['a','b']); moveWaypoint(9, 0)` producing `[undefined, 'a', 'b']`.
Resolved in spikersoft-angular PR #819 (merged to master). moveWaypoint no longer inserts undefined for an out-of-range fromIndex. Closing.
Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). moveWaypoint no longer inserts undefined for an out-of-range fromIndex. Closing.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Wave 7 tick 5 a3 coverage of
MarksMapStateService.moveWaypoint.Where:
projects/spikersoft/src/app/_services/marks-site/marks-map/marks-map-state.service.tsWhat:
moveWaypoint(fromIndex, toIndex)does:If
fromIndexis past the end of the list,splicereturns[], somovedItemisundefined, and that hole is inserted attoIndex. A UI that reorders waypoints from a stale index can grow a phantomundefinedstop and then crash when building a Directions request (waypoint.location.lat).removeWaypointalready no-ops for an out-of-range index (filter keeps the list).moveWaypointshould do the same — return unchanged whenfromIndexis not in range, rather than insertingundefined.Would have caught:
setWaypoints(['a','b']); moveWaypoint(9, 0)producing[undefined, 'a', 'b'].Resolved in spikersoft-angular PR #819 (merged to
master). moveWaypoint no longer inserts undefined for an out-of-range fromIndex. Closing.