Skip to content

Fix broken query strings in three methods - #11

Open
FrankBStack wants to merge 2 commits into
micahlt:masterfrom
FrankBStack:fix/query-string-urls
Open

FrankBStack wants to merge 2 commits into
micahlt:masterfrom
FrankBStack:fix/query-string-urls

Conversation

@FrankBStack

Copy link
Copy Markdown

Three of the client methods were building their query string with & instead of ?, so getUserContent, viewPollResults and getGroupChats were requesting paths like /v1/posts&type=my_posts and failing every time. Two of them broke in 2.6.6 when cacheBust got added, getUserContent has been that way for a while.

Fixed the three urls and rebuilt dist. Also added some unit tests that stub fetch and check what each method actually sends, since the existing test scripts all need a real token. They run with npm test, no new deps, and there's a small workflow so they run on PRs.

This is the small part pulled out of #10. That one's the refactor on top of this and can wait.

getUserContent, viewPollResults and getGroupChats were building URLs
like /v1/posts&type=my_posts, using & instead of ? for the first query
parameter. Since & is a valid path character the server received a route
that does not exist and every call to these methods failed. The latter
two regressed in 2.6.6 when cacheBust was added.

Adds a unit test suite (node --test, no dependencies) that stubs fetch
and asserts on the exact URL, method, headers and body each method
sends, so this class of bug is caught without a live token. Wired up as
`npm test`.

Also fixes updatesTest.js, which was passing the client instance itself
as the group ID, and rebuilds dist.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant