You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Current implementation parses and creates queryParams from this.href (see page.ts or cursor-based-page.ts). That is completely fine, however, we should be very careful how some characters get encoded by axios library.
To Reproduce
Steps to reproduce the behavior:
Perform any kind of search which returns Page and there are more results to fetch (query has to contain at least one space)
invoke getNextPage() on that Page
See results prop on returned Page is an empty array.
Expected behavior
returned Page contains newly fetched items.
Additional context
The cause of this bug was not obvious for me at first.
Call to getNextPage() uses queryParams which parses them from this.href.
That causes some params (query in this case) to have some symbols double parsed by axios (once from initial request, once from the subsequent request which passes already parsed URL params to axios)
Example:
// q=lil+pe => everything is fine (notice lil+pe) 👍constpage=awaitspotify.searchTracks('lil pe');/*query=lil%2BpeWe passed {query: 'lil+pe'} instead of {query: 'lil pe'} to axios params.That caused axios to parse + as %2B which causes Spotify to return no results*/constpage2=awaitpage.getNextPage();
The text was updated successfully, but these errors were encountered:
Not sure, the easiest solution would be to just replace + with spaces and then splitting this.href. But, imo, that is more like a bandaid than a solution
I think using the decodeURI function would be the best solution in this case. It should work just fine for this purpose, right?
Edit: Just saw that Spotify itself encodes spaces as +. I think that we need to do as @JoseRenan suggested, because replacing + with spaces could modify the original intent of the person making the search (if they actually put + in their query).
Describe the bug
Current implementation parses and creates queryParams from
this.href
(seepage.ts
orcursor-based-page.ts
). That is completely fine, however, we should be very careful how some characters get encoded by axios library.To Reproduce
Steps to reproduce the behavior:
Page
and there are more results to fetch (query has to contain at least one space)getNextPage()
on thatPage
results
prop on returnedPage
is an empty array.Expected behavior
returned
Page
contains newly fetched items.Additional context
The cause of this bug was not obvious for me at first.
Call to
getNextPage()
usesqueryParams
which parses them fromthis.href
.That causes some params (query in this case) to have some symbols double parsed by axios (once from initial request, once from the subsequent request which passes already parsed URL params to axios)
Example:
The text was updated successfully, but these errors were encountered: