Skip to content
Open
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
16 changes: 12 additions & 4 deletions src/components/RJST/Filters/PersistentFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function listFilterQuery(filters: JSONSchema[], stringify = true) {
}: FilterDescription & { operatorSlug?: string }) => ({
n: field,
o: operatorSlug ?? operator,
v: value,
v: JSON.stringify(value),
}),
);
});
Expand Down Expand Up @@ -119,20 +119,28 @@ export const loadRulesFromUrl = (
// https://github.com/ljharb/qs#parsing-primitivescalar-values-numbers-booleans-null-etc
// To handle this, we use a transformer to avoid scattering parsing logic across multiple filters.
let value: any = v;
const num = Number(v);
// Only try to transform the value from a string if the operator is not full text search and the field cannot be a string
if (typeof value === 'string') {
try {
value = JSON.parse(value);
} catch {
// If parsing fails, keep as string
}
}
// JSON.parse already handles numbers, booleans, null. Only handle remaining strings.
if (
typeof value === 'string' &&
o !== FULL_TEXT_SLUG &&
typeof properties[n] === 'object' &&
'type' in properties[n] &&
(Array.isArray(properties[n].type)
? !properties[n].type.includes('string')
: properties[n].type !== 'string')
) {
const num = Number(value);
if (!isNaN(num)) {
value = num;
} else {
switch (v) {
switch (value) {
case 'true':
value = true;
break;
Expand Down
Loading