Skip to content

Commit 66063c3

Browse files
authored
Release/v0.9.1 (#22)
* preparing for release v0.9.1 * feat(validation): Support array indexing in JSON path validation (#21) * feat(validation): Support array indexing in JSON path validation - Updated the JSON path validation regex to allow array indexing (e.g., `$.data[0].attribute`). - Ensured compatibility with dot notation for nested objects (e.g., `$.data.object.attribute`). - Improved validation to support mixed array and object paths (e.g., `$.data[0].nested[2].value`). - Added stricter checks to prevent malformed paths. * update engine version
1 parent 801c1a8 commit 66063c3

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "volt-test/php-sdk",
33
"description": "Volt Test PHP SDK - A performance testing tool for PHP applications",
44
"type": "library",
5-
"version": "0.9.0",
5+
"version": "0.9.1",
66
"keywords": [
77
"volt-test",
88
"php-sdk",

src/Extractors/JsonExtractor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public function validate(): bool
4444
if (empty($this->selector) || $this->selector === '$.') {
4545
throw new InvalidJsonPathException('JSON path cannot be empty');
4646
}
47-
// Validate the selector ex: $.meta.token
47+
// Validate the selector ex: $.meta.token or $.data[0].name
4848
// Validate the selector follows proper JSON path format
4949
// Should start with $ followed by dot and valid path segments
50-
if (! preg_match('/^\$(\.[a-zA-Z0-9_]+)*$/', $this->selector)) {
50+
$pattern = '/^\$(\.[a-zA-Z0-9_]+|\[[0-9]+\])*$/';
51+
if (! preg_match($pattern, $this->selector)) {
5152
throw new InvalidJsonPathException('Invalid JSON path');
5253
}
5354

src/Platform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Platform
66
{
77
private const BINARY_NAME = 'volt-test';
88

9-
private const ENGINE_CURRENT_VERSION = 'v0.1.1';
9+
private const ENGINE_CURRENT_VERSION = 'v0.9.1';
1010
private const BASE_DOWNLOAD_URL = 'https://github.com/volt-test/binaries/releases/download';
1111
private const SUPPORTED_PLATFORMS = [
1212
'linux-amd64' => 'volt-test-linux-amd64',

tests/Units/JsonExtractorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public static function validJsonPathProvider(): array
4646
['with_underscore'],
4747
['with.numbers.123'],
4848
['mixed.path_with.numbers123'],
49+
['mixed[0].path'],
50+
['mixed[0].path[1]'],
51+
['mixed[0].path[1].with[2].numbers[3]'],
4952
];
5053
}
5154

@@ -67,6 +70,12 @@ public static function invalidJsonPathProvider(): array
6770
['$invalid.start'],
6871
['invalid$.middle'],
6972
['path.with.$'],
73+
['$.data[abc]'],
74+
['$.data[0].name[abc]'],
75+
['$.data[0].name[0].'],
76+
['$.data[0].name[0].[1]'],
77+
['$.data[0].name[0].[1].'],
78+
['$.data[0].name[0].[1].name'],
7079
];
7180
}
7281

0 commit comments

Comments
 (0)