Skip to content

Commit 607ca29

Browse files
committed
Merge branch 'main' of https://github.com/platform-mesh/portal-ui-lib into list-blinking-fix
2 parents 158d11c + de3d1ae commit 607ca29

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@platform-mesh/portal-ui-lib",
3-
"version": "0.21.15",
3+
"version": "0.21.16",
44
"repository": {
55
"url": "git+https://github.com/platform-mesh/portal-ui-lib.git"
66
},

projects/lib/utils/utils/resource-field-by-path.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ describe('getResourceValueByJsonPath', () => {
4747
expect(result).toBe('test-result');
4848
});
4949

50+
it('should query resource using jsonPathExpression', () => {
51+
(jsonpath.query as jest.Mock).mockReturnValue(['test-result']);
52+
53+
const result = getResourceValueByJsonPath(mockResource, {
54+
jsonPathExpression: '$.spec.value',
55+
});
56+
57+
expect(jsonpath.query).toHaveBeenCalledWith(mockResource, '$.spec.value');
58+
expect(result).toBe('test-result');
59+
});
60+
5061
it('should query resource using property', () => {
5162
(jsonpath.query as jest.Mock).mockReturnValue(['property-result']);
5263

projects/lib/utils/utils/resource-field-by-path.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export const getResourceValueByJsonPath = (
2525
return undefined;
2626
}
2727

28-
const queryResult = jsonpath.query(resource, `$.${property}`);
28+
const prefix = property.startsWith('$.') ? '' : '$.';
29+
const queryResult = jsonpath.query(resource, `${prefix}${property}`);
2930
const value = queryResult.length ? queryResult[0] : undefined;
3031

3132
if (value && field.propertyField) {

0 commit comments

Comments
 (0)