Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions sdk/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.1] - 2025-04-10
### Added
- Fixed the issue with encoding keys for range and delete queries

## [1.0.0] - 2025-04-05
- First stable release
Expand Down
2 changes: 1 addition & 1 deletion sdk/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hpkv/rest-client",
"version": "1.0.0",
"version": "1.0.1",
"description": "A NodeJS REST client for high-performance key-value store (HPKV)",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
9 changes: 6 additions & 3 deletions sdk/node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ export class HPKVRestClient {
*/
async delete(key: string): Promise<RecordResponse> {
try {
return await this._request<RecordResponse>("DELETE", `/record/${key}`);
return await this._request<RecordResponse>(
"DELETE",
`/record/${encodeURIComponent(key)}`,
);
} catch (error) {
this._handleError(error as ApiError);
}
Expand Down Expand Up @@ -242,8 +245,8 @@ export class HPKVRestClient {
): Promise<RangeResponse> {
try {
const params = new URLSearchParams({
startKey,
endKey,
startKey: encodeURIComponent(startKey),
endKey: encodeURIComponent(endKey),
limit: limit.toString(),
});
return await this._request<RangeResponse>("GET", `/records?${params}`);
Expand Down
29 changes: 29 additions & 0 deletions sdk/node/tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,35 @@ describe("HPKVClient Integration Tests", () => {
expect(result.value).toBe(value);
});

test("should delete keys with special characters", async () => {
const key = getTestKey("special-delete:!@#$%^&*()_+");
testKeys.push(key);
const value = "Value to be deleted";

await client.set(key, value);
await client.delete(key);
await expect(client.get(key)).rejects.toThrow();
});

test("should handle range queries with special characters in keys", async () => {
const specialKeys = [
getTestKey("special-range:!@#$%^&*()_+:1"),
getTestKey("special-range:!@#$%^&*()_+:2"),
getTestKey("special-range:!@#$%^&*()_+:3"),
];

for (const key of specialKeys) {
testKeys.push(key);
await client.set(key, `Value for ${key}`);
}

const results = await client.range(specialKeys[0], specialKeys[2], 10);

expect(results.records).toHaveLength(3);
expect(results.truncated).toBe(false);
expect(results.records.map((r) => r.key)).toEqual(specialKeys);
});

test("should throw when value size exceeded", async () => {
const key = getTestKey("large");
testKeys.push(key);
Expand Down