Skip to content

Commit

Permalink
Issue 7: Erroneous "?" (#8)
Browse files Browse the repository at this point in the history
* return empty string if no query parameters are provided
  • Loading branch information
wolfpack94 authored Oct 30, 2019
1 parent 4e9b481 commit 049f046
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.1

- **Bug Fix**
- Remove erroneous `?` from query string when no query string parameters are provided

## 4.0.0

Because Dragonchain has a breaking change to replace its indexing solution, this is also a breaking SDK change for queries and custom indexing.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dragonchain-sdk",
"version": "4.0.0",
"version": "4.0.1",
"description": "Dragonchain SDK for Node.JS and the Browser",
"license": "Apache-2.0",
"homepage": "https://github.com/dragonchain/dragonchain-sdk-javascript#readme",
Expand Down
5 changes: 5 additions & 0 deletions src/services/dragonchain-client/DragonchainClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ describe('DragonchainClient', () => {
await client.getSmartContractLogs({ smartContractId: 'test', tail: 100, since: 'a-date' });
assert.calledWith(fetch, `fakeUrl/v1/contract/test/logs?tail=100&since=a-date`, expectedFetchOptions);
});

it('calls #fetch() with correct params and missing erroneous ?', async () => {
await client.getSmartContractLogs({ smartContractId: 'test' });
assert.calledWith(fetch, `fakeUrl/v1/contract/test/logs`, expectedFetchOptions);
});
});

describe('.getInterchainNetwork', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/dragonchain-client/DragonchainClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ export class DragonchainClient {
/**
* @hidden
*/
private generateQueryString = (queryObject: Map<string, string | number>) => `?${UrlSearchParams(queryObject)}`;
private generateQueryString = (queryObject: Map<string, string | number>) => (Object.keys(queryObject).length > 0 ? `?${UrlSearchParams(queryObject)}` : '');

/**
* @hidden
Expand Down

0 comments on commit 049f046

Please sign in to comment.