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

fix: encode URL parameters for :placeholder syntax #210

Merged
merged 4 commits into from
Oct 5, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add failing test case
Roman Balayan committed Oct 5, 2020
commit 303d0bc2e75794582daed90fc4d5fbcaf9c2bf91
17 changes: 17 additions & 0 deletions test/endpoint.test.ts
Original file line number Diff line number Diff line change
@@ -93,6 +93,23 @@ describe("endpoint()", () => {
});
});

it("Should properly handle either placeholder format on url", () => {
const { url: url1 } = endpoint(
"GET /repos/{owner}/{repo}/contents/{path}",
{
owner: "owner",
repo: "repo",
path: "path/to/file.txt",
}
);
const { url: url2 } = endpoint("GET /repos/:owner/:repo/contents/:path", {
owner: "owner",
repo: "repo",
path: "path/to/file.txt",
});
expect(url1).toEqual(url2);
});

it("Request body", () => {
const options = endpoint("POST /repos/:owner/:repo/issues", {
owner: "octocat",