Merge pull request #14551 from richard-cox/pagination-filter-quotes

SSP: Remove `=` from ssp search term filters
This commit is contained in:
Richard Cox 2025-06-20 18:02:11 +01:00 committed by GitHub
commit 3d4f281351
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 3 deletions

View File

@ -500,16 +500,25 @@ class StevePaginationUtils extends NamespaceProjectFilters {
// Check if the API supports filtering by this field
this.validateField(validateFields, schema, field.field);
const value = encodeURIComponent(field.value);
const encodedValue = encodeURIComponent(field.value);
// = exact match (equals + exact)
// ~ partial match (equals + !exact)
// != not exact match (!equals + exact)
// !~ not partial match (!equals + !exact)
const operator = `${ field.equals ? '' : '!' }${ field.exact ? '=' : '~' }`;
const quotedValue = StevePaginationUtils.VALID_FIELD_VALUE_REGEX.test(value) ? value : `"${ value }"`;
let safeValue;
return `${ this.convertArrayPath(field.field) }${ operator }${ quotedValue }`;
if (StevePaginationUtils.VALID_FIELD_VALUE_REGEX.test(field.value)) {
// Does not contain any protected characters, send as is
safeValue = encodedValue;
} else {
// Contains protected characters, wrap in quotes to ensure backend doesn't fail
// - replace reserver `"`/`%22` with empty string - see https://github.com/rancher/dashboard/issues/14549 for improvement
safeValue = `"${ encodedValue.replaceAll('%22', '') }"`;
}
return `${ this.convertArrayPath(field.field) }${ operator }${ safeValue }`;
}
return field.value;