1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-18 01:18:23 +02:00

fix: support search for tags that has colon inside (#7998)

Previously we expected the tag to look like `type:value`. Now we allow
everything after first colon, as the value and not break query
`type:this:still:is:value`.
This commit is contained in:
Jaanus Sellin 2024-08-28 11:33:51 +03:00 committed by GitHub
parent d5e4544fad
commit 3d22f6e909
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 5 deletions

View File

@ -604,11 +604,11 @@ const applyMultiQueryParams = (
): void => { ): void => {
queryParams.forEach((param) => { queryParams.forEach((param) => {
const values = param.values.map((val) => const values = param.values.map((val) =>
(Array.isArray(fields) ? val.split(':') : [val]).map((s) => (Array.isArray(fields)
s.trim(), ? val.split(/:(.+)/).filter(Boolean)
), : [val]
).map((s) => s.trim()),
); );
const baseSubQuery = createBaseQuery(values); const baseSubQuery = createBaseQuery(values);
switch (param.operator) { switch (param.operator) {

View File

@ -359,6 +359,20 @@ test('should filter features by tag', async () => {
await filterFeaturesByTag('EXCLUDE_ALL:simple,simple:jest', 400); await filterFeaturesByTag('EXCLUDE_ALL:simple,simple:jest', 400);
}); });
test('should filter features by tag that has colon inside', async () => {
await app.createFeature('my_feature_a');
await app.addTag('my_feature_a', {
type: 'simple',
value: 'my_tag:colon',
});
const { body } = await filterFeaturesByTag('INCLUDE:simple:my_tag:colon');
expect(body).toMatchObject({
features: [{ name: 'my_feature_a' }],
});
});
test('should filter features by environment status', async () => { test('should filter features by environment status', async () => {
await app.createFeature('my_feature_a'); await app.createFeature('my_feature_a');
await app.createFeature('my_feature_b'); await app.createFeature('my_feature_b');

View File

@ -63,7 +63,7 @@ export const featureSearchQueryParameters = [
schema: { schema: {
type: 'string', type: 'string',
pattern: pattern:
'^(INCLUDE|DO_NOT_INCLUDE|INCLUDE_ALL_OF|INCLUDE_ANY_OF|EXCLUDE_IF_ANY_OF|EXCLUDE_ALL):(?:\\s*[^,:]+:[^,:]+\\s*)(?:,\\s*[^,:]+:[^,:]+\\s*)*$', '^(INCLUDE|DO_NOT_INCLUDE|INCLUDE_ALL_OF|INCLUDE_ANY_OF|EXCLUDE_IF_ANY_OF|EXCLUDE_ALL):([^:,]+:.+?)(,\\s*[^:,]+:.+?)*$',
example: 'INCLUDE:simple:my_tag', example: 'INCLUDE:simple:my_tag',
}, },
description: description: