Skip to content

Commit

Permalink
Remove request url forward slash append (#264)
Browse files Browse the repository at this point in the history
remove request url forward slash append
  • Loading branch information
0xmaayan authored Jan 24, 2024
1 parent 4bad825 commit 95a54f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T

# Unreleased

- Remove request URLs forward slash append

# 1.4.0 (2024-01-08)

- Omit `"build" | "simulate" | "submit"` from `aptos` namespace
Expand Down
2 changes: 1 addition & 1 deletion src/client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function aptosRequest<Req extends {}, Res extends {}>(
aptosConfig: AptosConfig,
): Promise<AptosResponse<Req, Res>> {
const { url, path } = options;
const fullUrl = `${url}/${path ?? ""}`;
const fullUrl = path ? `${url}/${path}` : url;
const response = await request<Req, Res>({ ...options, url: fullUrl }, aptosConfig.client);

const result: AptosResponse<Req, Res> = {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/client/aptosRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe("aptos request", () => {
);
} catch (error: any) {
expect(error).toBeInstanceOf(AptosApiError);
expect(error.url).toBe(`${NetworkToIndexerAPI[config.network]}/`);
expect(error.url).toBe(`${NetworkToIndexerAPI[config.network]}`);
expect(error.status).toBe(200);
expect(error.statusText).toBe("OK");
expect(error.data).toHaveProperty("errors");
Expand Down

0 comments on commit 95a54f4

Please sign in to comment.