Skip to content

Pagination params not consistently constructed #347

Description

@dugsmith

I've found an issue in the way pagination params are added to generated URLs. It is easiest to describe in the context of your tests.

On this line of top_level_links_test.rb, you set a custom page_param to page[number]. And when you call Article.all on this line (currently 210), it works.

However, if you change that line to articles = Article.paginate(page: 1).all, then an extra page[] is wrapped around the param, so it becomes ?page[page[number]]=1 in the query string.

I've traced the issue to this line on query/builder.rb.

The problem is that we can't count on whether json_api_client is going to wrap page_param or per_page_param in page[]. I'd like it to be one way or the other.

I'm happy to fix it if you can give me direction as to which way you'd like it to go. It will likely be a breaking change either way. It should either always wrap page params with page[], or never. I'd lean towards always adding page[], since it is that way in the spec. However, we should just be consistent.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions