don't index outside of the path (closes #22312)