Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the host & protocol part of the links section using the origin property #961

Open
samislam opened this issue Aug 23, 2024 · 1 comment

Comments

@samislam
Copy link

I wanted to perform this and I thought it's gonna work:

 const dbEntries = await paginate(query, this.clientsRepo, {
      sortableColumns: getColumns(this.clientsRepo, true).names,
      select: getColumns(this.clientsRepo, true).names,
      origin: '', //  👈
    })

But it didn't, I wanted to change the links.cuurent origin, from:

 "links": {
        "current": "http://localhost:3001/clients?page=1&limit=20&sortBy=accountType:ASC&select=username,accountType"
    }

to

 "links": {
        "current": "/clients?page=1&limit=20&sortBy=accountType:ASC&select=username,accountType"
    }

But it doesn't work, I also tried to put "/", but it resulted in double slashes as follows:

 "links": {
        "current": "//clients?page=1&limit=20&sortBy=accountType:ASC&select=username,accountType"
    }

I think this is because the library somewhere in its code checks on the property if it exists by some approach like this:

if(!!origin) { /* do the `origin` logic */ }

I think it should handle this case by something like this:

if(origin == "" ||  !!origin) { /* do the `origin` logic */ }
@Helveg
Copy link
Collaborator

Helveg commented Aug 26, 2024

I like origin '/' more as a notation for this than ''. We'd love to see a PR for this with a test that verifies this works as expected :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants