humanmade / repress

Connect your Redux store to the WordPress REST API.
Other
83 stars 11 forks source link

indexOf returns -1, not null, for missing posts #39

Closed halmos closed 5 years ago

halmos commented 5 years ago

https://github.com/humanmade/repress/blob/fe825b9edd61a3b19f8ed0f7e8421e295c93da02/src/handler.js#L162-L165

The above code can result in a posts arrays containing elements with index value of -1 if the post.id is not found. I think the if statement should probably be:

if ( position === -1 ) {
  return null;
}
rmccue commented 5 years ago

Whoops, this looks like a copy-paste error. Can you send a pull request? :)

halmos commented 5 years ago

sure, just did. https://github.com/humanmade/repress/pull/40

rmccue commented 5 years ago

Fixed via 1c4c9ec7738bd86d8de36d7f6122d54c54169531 in #40