kadamwhite/wordpress-rest-api — pull request #79 by kadamwhite (2014-09-12 03:38:54+00:00)
Title: Fix exception when fetching empty collections

This crops up especially easily with search queries: no results, no paging; `x-wp-totalpages` got set to "0", a string, so the previous null check failed to catch the lack of pagination and an exception occurred when parsing the non-existent link header.

Example error:
```
Possibly unhandled TypeError: Cannot call method 'split' of undefined
at parse (~/wordpress-rest-api/node_modules/li/lib/index.js:15:33)
at paginateResponse (~/wordpress-rest-api/lib/shared/wp-request.js:229:14)
at PostsRequest.returnBody (~/wordpress-rest-api/lib/shared/wp-request.js:131:9)
[ ... ]
```
This PR breaks the existing no-paging => pass-through tests into three separate tests to validate different scenarios, and adds additional checks to return before the exception would occur.