json-api-php icon indicating copy to clipboard operation
json-api-php copied to clipboard

Paging links are duplicated unless removed from URI

Open shadowhand opened this issue 8 years ago • 2 comments

Unless the pagination links are removed from the URI passed to Document::addPaginationLinks() the output will be duplicated:

	"links": {
		"first": "https:\/\/api.acme.net\/users?page%5Blimit%5D=5?page%5Blimit%5D=5",
		"next": "https:\/\/api.acme.net/users?page%5Blimit%5D=5?page%5Blimit%5D=5&page%5Boffset%5D=5"
	}

It should be clearly documented that the passed URI must be stripped of query parameters or addPaginationLinks should automatically strip them.

shadowhand avatar Jun 17 '17 03:06 shadowhand

The second parameter is an array of query parameters, so that should make it clear, right? On the other hand, maybe the first parameter can be called $path?

In any case, any improvements should probably be added to the new API.

franzliedke avatar Jun 17 '17 10:06 franzliedke

@franzliedke I'm not sure what the correct solution is, perhaps just discarding ?.* from the $uri. Right now the documentation just isn't clear about the fact that query params should not be in $uri.

shadowhand avatar Jun 19 '17 21:06 shadowhand