Skip to content

Commit caf8342

Browse files
committed
GitHub Issue 966: Grid filter UI parses URL parameter incorrectly for array data
1 parent 54a8dfd commit caf8342

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 1.X - 2026-X
2+
- GitHub Issue 966: Grid filter UI parses URL parameter incorrectly for array data
3+
14
### 1.51.0 - 2026-03-31
25
- Package updates
36

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": "@labkey/api",
3-
"version": "1.51.0",
3+
"version": "1.51.1-mvtcBatch3.1",
44
"description": "JavaScript client API for LabKey Server",
55
"scripts": {
66
"build": "npm run build:dist && npm run build:docs",

src/labkey/filter/Types.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ describe('parseValue', () => {
8282
expect(type.parseValue(value)).toEqual(['value1', 'value2', 'value3']);
8383
});
8484

85+
it('should parse JSON formatted values containing closing brace in value', () => {
86+
const type = Types.IN;
87+
const value = '{json:["a}b;c"]}';
88+
expect(type.parseValue(value)).toEqual(['a}b;c']);
89+
});
90+
91+
it('should round-trip values containing both separator and closing brace', () => {
92+
const type = Types.IN;
93+
const original = ['a}b;c', 'x;y}z'];
94+
const encoded = type.getURLParameterValue(original);
95+
expect(encoded).toBe('{json:["a}b;c","x;y}z"]}');
96+
expect(type.parseValue(encoded)).toEqual(original);
97+
});
98+
8599
it('should fall back to regex parsing if JSON is invalid', () => {
86100
const type = Types.IN;
87101
// Invalid JSON: missing closing quote for value2

src/labkey/filter/Types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,8 @@ export function getFilterTypesForType(jsonType: JsonType, mvEnabled?: boolean):
561561
const NEW_LINE_SEP = '\n';
562562

563563
export function parseMultiValueFilterString(type: IFilterType, value: string) {
564-
if (value.indexOf('{json:') === 0 && value.indexOf('}') === value.length - 1) {
564+
// GH Issue 966: Grid filter UI parses URL parameter incorrectly for value a}b;c
565+
if (value.startsWith('{json:') && value.endsWith('}')) {
565566
try {
566567
return JSON.parse(value.substring('{json:'.length, value.length - 1));
567568
} catch {

0 commit comments

Comments
 (0)